Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

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

by thimes (Acolyte)
on Feb 15, 2017 at 01:59 UTC ( [id://1182039]=note: print w/replies, xml ) Need Help??


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

Yes I was referring to the Perl DateTime module. But I'm not stuck on using that. My problem is this. 1. I must use the epoch 2000 Jan 1, 12:00:00 (UTC) That's 12noon. 2. From that epoch I will be given both beginning and end time boundaries in the future. 3. I will need to add/sub seconds from either of those boundaries. 4. Then convert back to readable form in UTC.
  • Comment on Re^2: How to use a different epoch with DateTime

Replies are listed 'Best First'.
Re^3: How to use a different epoch with DateTime
by anita2R (Scribe) on Feb 15, 2017 at 13:09 UTC

    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.

      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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1182039]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-04-16 16:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found