Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^3: How to use a different epoch with DateTime

by anita2R (Scribe)
on Feb 15, 2017 at 13:09 UTC ( #1182059=note: print w/replies, xml ) Need Help??


in reply to Re^2: How to use a different epoch with DateTime
in thread How to use a different epoch with DateTime

DateTime is probably not the best module to use, particularly as you are going forward and don't need dates before the start of the Gregorian calendar. The man page for DateTime notes that it does not account for leap seconds, so your results may be out.

The default time zone for new DateTime objects, except where stated otherwise, is the "floating" time zone. This concept comes from the iCal standard. A floating datetime is one which is not anchored to any particular time zone. In addition, floating datetimes do not include leap seconds, since we cannot apply them without knowing the datetime's time zone. The results of date math and comparison between a floating datetime and one with a real time zone are not really valid, because one includes leap seconds and the other does not. Similarly, the results of datetime math between two floating datetimes and two datetimes with time zones are not really comparable.

As suggested by thomas895 create your new epoch seconds for the new dates given, calculate the epoch seconds for 01 January 2000, noon, and subtract it from the epoch seconds for new dates given.

The number of seconds difference between future dates will be the same whatever the base epoch date is.

  • Comment on Re^3: How to use a different epoch with DateTime

Replies are listed 'Best First'.
Re^4: How to use a different epoch with DateTime
by haukex (Bishop) on Feb 16, 2017 at 09:16 UTC

    Hi anita2R,

    The man page for DateTime notes that it does not account for leap seconds, so your results may be out.

    The section of the doc you are quoting refers only to the special "floating" time zone (Update: I consider the "floating" time zone to be the equivalent of "no time zone"). When you specify any time zone (including UTC), DateTime does handle leap seconds.

    Regards,
    -- Hauke D

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1182059]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2020-11-24 03:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?