Re: Date/Time conversions

new topic     » goto parent     » topic index » view thread      » older message » newer message

Cool, I actually tried not to use specific 4.0 features but I didn't remember poke2/peek2 weren't there.

PS: My code could be modified to use sequences when peeking/poking if you're looking for speed crazy speed :)

Edit: If I understood correctly, you can see the difference between GMT 0 and your current timezone using now() and now_gmt() on Eu4 http://openeuphoria.org/docs/std_datetime.html#_1030_now_gmt

Edit2: It worked! :)
FYI, this may not be so accurate since we are calling now and now_gmt which in the middle the system could hog or something (weird but could happen), if you really need to be sure, you can remove the seconds from now and now_gmt and set them to 0 (if your system is so busy for a minute, there's a bigger problem!).

 
include std/datetime.e as dtf 
 
sequence rightnow = dtf:now() 
sequence rightnowgmt0 = dtf:now_gmt() 
-- Calculate the difference between your machine timezone and GMT0 
atom gmt0diff = dtf:diff(rightnowgmt0, rightnow) 
 
-- Create Euphoria datetime 
sequence yourdate = dtf:new(2012,3,25,23,30,0) 
 
-- Calculate difference 
?dtf:add(yourdate,gmt0diff,dtf:SECONDS) 
-- Print {2012,3,25,20,30,0} which is GMT-3! :) 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu