[PD] Pd+pachube+python

Mathieu Bouchard matju at artengine.ca
Sun Dec 12 15:51:41 CET 2010


On Sat, 11 Dec 2010, FernandoG wrote:

> script is adapted to the specific data feed, and this data is a vector 
> with tree elements ( ['0', '2010-12-11T22:11:34.480041Z', '7.6']). First 
> I delate  second elemnt(2010-12-11T22:11:34.480041Z) because i dont know 
> how to cast it and i dont need the date. There is the python code:

What I recommend for dates in Pd, is to put it as a triplet of integers 
(represented as floats). First put the date as a standard unix number, 
adjusted in the timezone you choose to use. Then separate it in three 
parts : $3 is for microseconds, from 0 to 999999 ; $2 is for seconds in a 
day, using % 86400; $1 is for the day number, using / 86400 ; for example,
your above date is :

   1292105494.480041 in epoch format
   $3 = 480041
   1292105494 is rounded downwards, in whole seconds
   $2 = 1292105494 % 86400 = 79894
   $1 = 1292105494 / 86400 = 14954

I don't know any Python. I just know that it's quite similar to Ruby, and 
in Ruby, when I print Time.new.to_f, I get a double (float64) that says 
something like 1292105494.480041, so, I suppose you can find a way to get 
the same.

The above triplet of numbers is output by the middle outlet of my external 
named [unix_time] :

   http://gridflow.ca/help/unix_time-help.html

  _______________________________________________________________________
| Mathieu Bouchard ---- tél: +1.514.383.3801 ---- Villeray, Montréal, QC


More information about the Pd-list mailing list