Subject: | Allow default timezone other than "floating" |
My client would desperately love official DateTime support for a default time zone.
The following shows my problem:
$ perl -MDateTime -E 'say DateTime->new( year => 2016, month => 4, day => 23 )->time_zone->name'
floating
$ perl -MDateTime -E 'say DateTime->now->time_zone->name'
UTC
I have a US-based client with a very large I18N project and for years they've ignored the time zone on DateTime objects, thus causing their code to be a mixture of "floating" and "UTC" time zones. Sometimes they remember to set their time zone to America/Los_Angeles, but not always. Worse, some external tools such as DateTime::Format::MySQL assume the floating time zone, but others such as DateTime::Format::SQLite assume UTC, which means virtually identical software stacks can have significantly different behavior.
We cannot (yet) migrate all of our dates to UTC, so for the time being, I've written a DBIx::Class inflator which forces the LA time zone. However, I can't control all of the places where DateTime objects are generated in our code. Further, because so much of the Perl ecosystem assumes DateTime objects and won't allow us to easily generate a subclass of DateTime, even that route has proved to be unworkable.
Having a config file or an environment variable which allows us to set different defaults to DateTime would be very helpful. Our current approach is monkey-patching or worse, maintaining an internal DateTime fork.
Best,
Ovid