Erlang/OTP Forums

Author Message

<  Erlang bugs mailing list  ~  Wrong gregorian date

Guest
Posted: Mon Mar 01, 2010 2:04 pm Reply with quote
Guest
Hello.

It seems a part of calendar library thinks there is February 29, 2010.

# date +%s
1267451701

Eshell V5.7.4 (abort with ^G)
1> calendar:gregorian_seconds_to_datetime(1267451701).
{{40,2,29},{13,55,1}}


Best regards,
Sergei Fomin



________________________________________________________________
erlang-bugs (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:erlang-bugs-unsubscribe@erlang.org

Post received from mailinglist
Guest
Posted: Mon Mar 01, 2010 2:36 pm Reply with quote
Guest
Oh, my fault.
Thank you.

Best regards,
Sergei Fomin




Trevor Woollacott [ MTN - Innovation Centre ] wrote:
> Hi Sergei
>
> Date +%s does not return the date and time in Gregorian seconds, rather the number of seconds since 1970-01-01 00:00:00 UTC. If you try to convert the number of seconds since 1970 back to into the date & time tuple it correctly calculates the year at 40AD, which is a leap year.
>
> Regards,
> Trevor
>
>
> -----Original Message-----
> From: erlang-bugs@erlang.org [mailto:erlang-bugs@erlang.org] On Behalf Of Sergei Fomin
> Sent: Monday, 01 March 2010 04:05 PM
> To: erlang-bugs@erlang.org
> Subject: [erlang-bugs] Wrong gregorian date
>
> Hello.
>
> It seems a part of calendar library thinks there is February 29, 2010.
>
> # date +%s
> 1267451701
>
> Eshell V5.7.4 (abort with ^G)
> 1> calendar:gregorian_seconds_to_datetime(1267451701).
> {{40,2,29},{13,55,1}}
>
>
> Best regards,
> Sergei Fomin
>
>
>
> ________________________________________________________________
> erlang-bugs (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-bugs-unsubscribe@erlang.org
>
>
> NOTE: This e-mail message is subject to the MTN Group disclaimer see http://www.mtn.co.za/SUPPORT/LEGAL/Pages/EmailDisclaimer.aspx
>

________________________________________________________________
erlang-bugs (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:erlang-bugs-unsubscribe@erlang.org

Post received from mailinglist
TrevorWoollacott
Posted: Mon Mar 01, 2010 2:42 pm Reply with quote
Joined: 27 Jul 2007 Posts: 8
Hi Sergei

Date +%s does not return the date and time in Gregorian seconds, rather the number of seconds since 1970-01-01 00:00:00 UTC. If you try to convert the number of seconds since 1970 back to into the date & time tuple it correctly calculates the year at 40AD, which is a leap year.

Regards,
Trevor


-----Original Message-----
From: erlang-bugs@erlang.org [mailto:erlang-bugs@erlang.org] On Behalf Of Sergei Fomin
Sent: Monday, 01 March 2010 04:05 PM
To: erlang-bugs@erlang.org
Subject: [erlang-bugs] Wrong gregorian date

Hello.

It seems a part of calendar library thinks there is February 29, 2010.

# date +%s
1267451701

Eshell V5.7.4 (abort with ^G)
1> calendar:gregorian_seconds_to_datetime(1267451701).
{{40,2,29},{13,55,1}}


Best regards,
Sergei Fomin



________________________________________________________________
erlang-bugs (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:erlang-bugs-unsubscribe@erlang.org


NOTE: This e-mail message is subject to the MTN Group disclaimer see http://www.mtn.co.za/SUPPORT/LEGAL/Pages/EmailDisclaimer.aspx

________________________________________________________________
erlang-bugs (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:erlang-bugs-unsubscribe@erlang.org

Post received from mailinglist
View user's profile Send private message
Guest
Posted: Mon Mar 01, 2010 3:29 pm Reply with quote
Guest
But the date you provided is not gregorian seconds.
try
calendar:datetime_to_gregorian_seconds({date(),time()}).
63434683473
.
The result you actually got is February 29, 2040 - you can ensure that this
year is leap year Smile.


On Mon, Mar 1, 2010 at 4:05 PM, Sergei Fomin <dafgar@yandex-team.ru> wrote:

> Hello.
>
> It seems a part of calendar library thinks there is February 29, 2010.
>
> # date +%s
> 1267451701
>
> Eshell V5.7.4 (abort with ^G)
> 1> calendar:gregorian_seconds_to_datetime(1267451701).
> {{40,2,29},{13,55,1}}
>
>
> Best regards,
> Sergei Fomin
>
>
>
> ________________________________________________________________
> erlang-bugs (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-bugs-unsubscribe@erlang.org
>
>


--
Best regards,
Alex Kutsko


Post received from mailinglist
Guest
Posted: Mon Mar 01, 2010 3:34 pm Reply with quote
Guest
Sorry to be precise you've got February, 29 of 0040 year

On Mon, Mar 1, 2010 at 5:29 PM, Alex Kutsko <alex.kutsko@itteco.com> wrote:

> But the date you provided is not gregorian seconds.
> try
> calendar:datetime_to_gregorian_seconds({date(),time()}).
> 63434683473
> .
> The result you actually got is February 29, 2040 - you can ensure that this
> year is leap year Smile.
>
>
>
> On Mon, Mar 1, 2010 at 4:05 PM, Sergei Fomin <dafgar@yandex-team.ru>wrote:
>
>> Hello.
>>
>> It seems a part of calendar library thinks there is February 29, 2010.
>>
>> # date +%s
>> 1267451701
>>
>> Eshell V5.7.4 (abort with ^G)
>> 1> calendar:gregorian_seconds_to_datetime(1267451701).
>> {{40,2,29},{13,55,1}}
>>
>>
>> Best regards,
>> Sergei Fomin
>>
>>
>>
>> ________________________________________________________________
>> erlang-bugs (at) erlang.org mailing list.
>> See http://www.erlang.org/faq.html
>> To unsubscribe; mailto:erlang-bugs-unsubscribe@erlang.org
>>
>>
>
>
> --
> Best regards,
> Alex Kutsko
>



--
Best regards,
Alex Kutsko


Post received from mailinglist
Guest
Posted: Tue Mar 02, 2010 4:34 am Reply with quote
Guest
So Sergei should use :

calendar:gregorian_seconds_to_datetime(1267451701+62167219200).

Where does that magic number "62167219200" come from? Here:
calendar:datetime_to_gregorian_seconds({{1970, 1, 1}, {0,0,0}}).

Thijs Terlouw
Shenzhen, China,
http://www.startinchina.com/



On Mon, Mar 1, 2010 at 11:33 PM, Alex Kutsko <alex.kutsko@itteco.com> wrote:
> Sorry to be precise you've got February, 29 of 0040 year
>
> On Mon, Mar 1, 2010 at 5:29 PM, Alex Kutsko <alex.kutsko@itteco.com> wrote:
>
>> But the date you provided is not gregorian seconds.
>> try
>> calendar:datetime_to_gregorian_seconds({date(),time()}).
>> 63434683473
>> .
>> The result you actually got is February 29, 2040 - you can ensure that this
>> year is leap year Smile.
>>
>>
>>
>> On Mon, Mar 1, 2010 at 4:05 PM, Sergei Fomin <dafgar@yandex-team.ru>wrote:
>>
>>> Hello.
>>>
>>> It seems a part of calendar library thinks there is February 29, 2010.
>>>
>>> # date +%s
>>> 1267451701
>>>
>>> Eshell V5.7.4  (abort with ^G)
>>> 1> calendar:gregorian_seconds_to_datetime(1267451701).
>>> {{40,2,29},{13,55,1}}
>>>
>>>
>>> Best regards,
>>> Sergei Fomin
>>>
>>>
>>>
>>> ________________________________________________________________
>>> erlang-bugs (at) erlang.org mailing list.
>>> See http://www.erlang.org/faq.html
>>> To unsubscribe; mailto:erlang-bugs-unsubscribe@erlang.org
>>>
>>>
>>
>>
>> --
>> Best regards,
>> Alex Kutsko
>>
>
>
>
> --
> Best regards,
> Alex Kutsko
>

________________________________________________________________
erlang-bugs (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:erlang-bugs-unsubscribe@erlang.org

Post received from mailinglist

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum