[html-formfu] time_zone with DateTime element

rahed raherh at gmail.com
Wed Mar 31 11:34:31 GMT 2010


Carl Franks <fireartist at gmail.com> writes:

> I've added a new method on the Date element (which DateTime
> subclasses) that allows you to set values on the DateTime object
> before it's used.
> See the docs for details.
> It's in svn -r1698, and will be in the next CPAN release.

Hi,

I patched -r1698. When DateTime::Format::Natural object is being created
its time_zone attribute must be set.


--- Date.pm	Wed Mar 31 13:12:59 2010
+++ Date.pmnew	Wed Mar 31 13:11:37 2010
@@ -152,8 +152,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 ) {
         my $is_blessed = blessed($default);


-- 
Radek



More information about the HTML-FormFu mailing list