Subject: | time_zone with DateTime element |
DateTime element does not honour hours with respect to local time zone.
It was discussed in the mailing list of 25 - 31 March. The latest
version behaves same as 0.06001.
Included are patches for Element/Date.pm and
date_default_datetime_args.t.
Time zone of DateTime::Format::Natural object must be set during its
creation not after in Element/Date.pm.
Thank you.
Radek
Subject: | Date.pm.patch |
--- Date.pm Wed Jul 7 11:36:10 2010
+++ Date.pmnew Wed Jul 7 11:30:44 2010
@@ -153,8 +153,18 @@
my $default;
if ( defined( $default = $self->default_natural ) ) {
- my $parser = DateTime::Format::Natural->new;
- $default = $parser->parse_datetime($default);
+ my $parser;
+ if ( defined( my $datetime_args = $self->default_datetime_args ) ) {
+ if (defined$$datetime_args{set_time_zone}) {
+ my $tz = $$datetime_args{set_time_zone};
+ $parser = DateTime::Format::Natural->new(time_zone => $tz);
+ } else {
+ $parser = DateTime::Format::Natural->new();
+ }
+ } else {
+ $parser = DateTime::Format::Natural->new();
+ }
+ $default = $parser->parse_datetime($default);
}
elsif ( defined( $default = $self->default ) && length $default ) {
Subject: | date_default_datetime_args.t.patch |
--- date_default_datetime_args.t Wed Jul 7 11:45:53 2010
+++ date_default_datetime_args.tnew Wed Jul 7 11:40:13 2010
@@ -13,7 +13,9 @@
$form->process;
{
- my $dt = DateTime->now(time_zone => 'Europe/Berlin');
+ my $parser = DateTime::Format::Natural->new;
+ my $dt = $parser->parse_datetime( 'now' );
+ $dt->set_time_zone( 'Europe/Berlin' );
my $foo = $form->get_field('foo');