Hello! I'm attaching a small patch which provides the ability to pass a time_zone parameter to the DateTime inflator, in this fashion:
inflators => [{ type => 'DateTime', time_zone => 'Europe/Helsinki', parser => { strptime => "%Y-%m-%d %H:%M" }, }], This allows the DateTime object created from a string which does not contain time zone information to be returned in a definite time zone instead of the floating one. I find this particularly useful in my code in this way (Catalyst example): time_zone => $c->stash->{userdata}->time_zone', This allows me to have date and time the user enters automatically stored with the correct time zone, if if he/she doesn't indicate it (which happens all the time). As usual, I'll provide docs and tests is the patch gets accepted. ;) Thanks, Michele. -- Michele Beltrame http://www.cattlegrid.info/ ICQ 76660101 - MSN [EMAIL PROTECTED]
--- home/mb/devel/formfu/trunk/HTML-FormFu/lib/HTML/FormFu/Inflator/DateTime.pm +++ u/www/cheiron/cryo/Cryo/lib/HTML/FormFu/Inflator/DateTime.pm @@ -7,7 +7,7 @@ use DateTime::Format::Builder; use DateTime::Format::Strptime; -__PACKAGE__->mk_accessors(qw/ strptime _builder /); +__PACKAGE__->mk_accessors(qw/ strptime time_zone _builder /); sub new { my $self = shift->next::method(@_); @@ -44,6 +44,10 @@ my $formatter = DateTime::Format::Strptime->new(%args); $dt->set_formatter($formatter); + } + + if ( defined $self->time_zone ) { + $dt->set_time_zone( $self->time_zone ); } return $dt;
_______________________________________________ HTML-FormFu mailing list HTML-FormFu@lists.scsys.co.uk http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu