And if it were present, am I alone in finding it useful for the Format modules, such as DT::F::MySQL, where the zoneless strings are forced into the 'floating' timezone?
Although it is not strictly true that MySQL is timezone agnostic. You could construct a local datetime using the result of MySQL's UNIX_TIMESTAMP() function with DateTime's from_epoch() and set the tz to 'local' -- the unix timestamp returned from MySQL appears to observe the timezone of the local machine.
As it now stands, DT::F::MySQL does not behave symmetrically for local DateTimes:
use DateTime; use DateTime::Format::MySQL;
$F = 'DateTime::Format::MySQL';
$now = DateTime->now(time_zone => 'local');
print "now: ", $now->datetime, "\n";
print "tz: ", $now->time_zone_long_name, "\n";
$mdt = $F->format_datetime($now);
print "mdt: $mdt\n";
$now = $F->parse_datetime($mdt);
print "now2: ", $now->datetime, "\n";
print "tz2: ", $now->time_zone_long_name, "\n";
$now->set_time_zone('local');
print "now2: ", $now->datetime, "\n";
print "tz2: ", $now->time_zone_long_name, "\n";In order to get symmetry, you have to first set_time_zone('UTC') to convert from 'floating', then set_time_zone('local') to get back to the original time.
Am I going about this the wrong way?
Thanks, Matt
