Timezones handling

Mariano Montone marianomontone at gmail.com
Sun Dec 6 03:04:30 UTC 2015


Hello,

I have a question regarding timestamps and timezones.

I'm not getting the numbers I expect when I do some time calculations.

I'm following this article on timezones handling:
http://www.creativedeletion.com/2015/05/10/the-need-timezones.html

It shows this example:

iex> at_four = DateTime.from_erl!({{2014,3,30},{4,00,00}},
"Europe/Stockholm")
iex> at_one =  DateTime.from_erl!({{2014,3,30},{1,00,00}},
"Europe/Stockholm")
iex> DateTime.diff(at_four, at_one)
{:ok, 7200, 0}
# 7200 seconds is two hours in this case

Now, if I try something similar with local-time, I get three hours,
instead of 2, which I assume is incorrect:

CL-USER> (defparameter *at-four* (local-time:encode-timestamp 0 0 0 4 30
3 2014 :timezone (local-time:find-timezone-by-location-name
"Europe/Stockholm")))
*AT-FOUR*
CL-USER> (defparameter *at-one* (local-time:encode-timestamp 0 0 0 1 30
3 2014 :timezone (local-time:find-timezone-by-location-name
"Europe/Stockholm")))
*AT-ONE*
CL-USER> *at-four*
@2014-03-30T04:00:00.000000+02:00
CL-USER> *at-one*
@2014-03-30T00:00:00.000000+01:00
CL-USER> (local-time:timestamp-difference *at-four* *at-one*)
10800

I've also tested this with Python libraries, and it also gives the
correct answer (2 hours instead of 3).

Is this a bug? Is this something that is not supported by local-time
library?

Sorry for bothering with this. I'm evaluating libraries and stuff
because I'm developing a calendar application that turns out to be in
Common Lisp and this kind of thing is important.

Thanks

Mariano



More information about the local-time-devel mailing list