On Fri, Mar 08, 2013 at 07:06:32AM -0800, Bill Moseley wrote:
> With fifteen or so developers with all different levels of Perl skills not
> all are going to understand or know the specifics of when duration math
> might fail.   And the hard part is it might not fail for months or years
> after the code is written.
> ...  But,  I'm
> wondering if there's an idiom or rule I could provide them so that the math
> will at least not fail.
> Like, "always defined durations in terms of hours" (or seconds?) or "always
> convert to UTC before adding a duration".

my $0.02: **always** store timestamps in ISO8601 format (UTC), or in unix
epoch (integer) format **only**.  Local timezones should only get applied
when rendering data for user consumption - i.e. as late as possible, and
after all calculations have been performed.  When processing timestamps
input by a user, convert to UTC as soon as possible, before storage and
before applying any math.

There's a good (and lengthy) discussion at
https://metacpan.org/module/DateTime#How-DateTime-Math-Works, which ends
with very similar advice.

Reply via email to