DateTools.delta

50 views
Skip to first unread message

Michel Romecki

unread,
Jul 16, 2015, 9:52:11 AM7/16/15
to haxe...@googlegroups.com
Hej,
I'm not really familiar with dates (...that's probably why I can't
remember any birthdays too :p) but when doing this :
DateTools.format( Date.fromTime( call.endDatetime.getTime() -
call.startDatetime.getTime() ), "%H:%M:%S" )
I get 1 hour and 2 seconds when expected only 2 seconds ... There is
always +1 hour, why please ?

Juraj Kirchheim

unread,
Jul 16, 2015, 10:04:03 AM7/16/15
to haxe...@googlegroups.com
Look here: http://try.haxe.org/#567B7

Date.fromTime(0) is Thu Jan 01 1970 01:00:00 GMT+0100, because in January, your time zone is GMT+1.

There's a couple of date libraries out there to with time zones and what not. This is the most complete one I know of: http://lib.haxe.org/p/datetime/

What you want is called a DateTimeInterval in that library and you can format it like so: http://doc.stablex.ru/datetime/DateTimeInterval.html#format

Best,
Juraj



--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
--- You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.

Michel Romecki

unread,
Jul 16, 2015, 11:54:32 AM7/16/15
to haxe...@googlegroups.com
Oh Thanks again Juraj ! ;)

Nicolas Cannasse

unread,
Jul 16, 2015, 5:09:17 PM7/16/15
to haxe...@googlegroups.com
Because of time shift. fromTime takes an UTC time not a local time. So when you print it it prints the local time for the  1st January 1970 00:00:02 UTC in your timezone. You can easily move to London to fix the issue.

Best,
Nicolas

On Thu, Jul 16, 2015 at 3:52 PM, Michel Romecki <filt...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages