Timezones handling
Siebe
Siebe at de-Vos.de
Mon Dec 7 09:02:47 UTC 2015
Hi Mariano,
The attached patch solves your problem with an improvement to %get-offset.
@Attila: I was never sure enough to submit this as a patch, but it has
worked for us for many years. Maybe you want to merge it and some of the
other changes too.
Bye,
Siebe
On 2015-12-06 04:04, Mariano Montone wrote:
> 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
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: local-time.patch
Type: text/x-patch
Size: 21199 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/local-time-devel/attachments/20151207/72d5a7e9/attachment.bin>
More information about the local-time-devel
mailing list