in reply to Re: Simple date and time manipulation
in thread Simple date and time manipulation

The UNIX epoch timestamp, being the number of seconds elapsed since midnight Coordinated Universal Time (UTC) of January 1, 1970, not counting leap seconds has no problems with daylight savings time adjustments. That is something you will have to look into only at the level of printing "human readable" output for a particular time-zone.

The internal format is therefore best left and stored as a timestamp and converted into whatever you need upon preparing the output.

The docs at DateTime say:

use UTC for all calculations

If you do care about time zones (particularly DST) or leap seconds, try to use non-UTC time zones for presentation and user input only. Convert to UTC immediately and convert back to the local time zone for presentation:

Arguably DateTime is the best for making such conversions, but yes it is a heavy and relatively slow module, but you pay that price only once at start-up.

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

  • Comment on Re^2: Simple date and time manipulation