We don't bite newbies here... much | |
PerlMonks |
Re: How to use a different epoch with DateTimeby anita2R (Scribe) |
on Feb 14, 2017 at 21:37 UTC ( [id://1182007]=note: print w/replies, xml ) | Need Help?? |
Does the system you work on have its epoch set to zero for 01 January 2000, or does it use the standard Linux epoch of 01 January 1970? (I am ignoring the issue of whether your year 2000 epoch starts at midnight or at noon!) Try this to see what it's set at:
If the 2K epoch is zero, then you shouldn't have to do anything, as all calculations will be using that epoch. As long as the calculated seconds are not transferred to another system that is using the Linux epoch there shouldn't be any problems, but it's not something I can test. If however your system is using standard Linux epoch ($linux_epoch is zero) the you will have to subtract the year 2000 value from all calculated seconds and add it back again before converting seconds back to eye-readable values. You will still need to know whether you are working in UTC or local time. When you used 'DateTime' in your question title, did you specifically mean the perl DateTime module, or just any date and time module. From what I have just read, DateTime uses an epoch based on year 1 (long before the Gregorian calendar was invented), In this calendar, the first day of the calendar (the epoch), is the first day of year 1As an aside, I like Date::Calc as I do a fair bit of adding/subtracting days or hours from start dates/times
In Section
Seekers of Perl Wisdom
|
|