[Jifty-commit] r4891 - in jifty/trunk: . lib/Jifty

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Mon Jan 21 00:25:54 EST 2008


Author: sartak
Date: Mon Jan 21 00:25:53 2008
New Revision: 4891

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/lib/Jifty/DateTime.pm
   jifty/trunk/lib/Jifty/Filter/DateTime.pm

Log:
 r50572 at onn:  sartak | 2008-01-21 00:24:48 -0500
 A fix for a time zone bug exposed by Doxory: copy the time_zone from JDBI::Filter, but allow for overriding it


Modified: jifty/trunk/lib/Jifty/DateTime.pm
==============================================================================
--- jifty/trunk/lib/Jifty/DateTime.pm	(original)
+++ jifty/trunk/lib/Jifty/DateTime.pm	Mon Jan 21 00:25:53 2008
@@ -57,6 +57,9 @@
 sub new {
     my $class = shift;
     my %args  = (@_);
+
+    my $replace_tz = delete $args{_replace_time_zone};
+
     my $self  = $class->SUPER::new(%args);
 
     # XXX What if they really mean midnight offset by time zone?
@@ -69,15 +72,16 @@
     # 00:00:00 implies that no time is used
     if ($self->hour || $self->minute || $self->second) {
 
-        # Unless the user has explicitly said they want a floating time,
+        # Unless the user has explicitly said they want a time zone,
         # we want to convert to the end-user's timezone. If we ignore
         # $args{time_zone}, then DateTime::from_epoch will get very confused
-        if (!$args{time_zone} and my $tz = $self->current_user_has_timezone) {
+        if (!$args{time_zone} || $replace_tz) {
+            if (my $tz = $self->current_user_has_timezone) {
+                # XXX: we do this because of the floating timezone
+                $self->set_time_zone("UTC");
 
-            # XXX: we do this because of the floating timezone
-            $self->set_time_zone("UTC");
-
-            $self->set_time_zone( $tz );
+                $self->set_time_zone( $tz );
+            }
         }
     }
 

Modified: jifty/trunk/lib/Jifty/Filter/DateTime.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Filter/DateTime.pm	(original)
+++ jifty/trunk/lib/Jifty/Filter/DateTime.pm	Mon Jan 21 00:25:53 2008
@@ -53,13 +53,14 @@
 
     # XXX There has to be a better way to do this
     my %args;
-    for (qw(year month day hour minute second nanosecond formatter)) {
+    for (qw(year month day hour minute second nanosecond time_zone formatter)) {
         $args{$_} = $$value_ref->$_ if(defined($$value_ref->$_));
     }
 
-    # the floating timezone indicates a date, so we don't want to set any
-    # other timezone on it
-    $args{time_zone} = 'floating' if $$value_ref->time_zone =~ /floating/i;
+    # we want this DateTime's TZ to be in the current user's TZ, unless
+    # it represents a date
+    $args{_replace_time_zone} = 1
+        unless $args{time_zone} =~ /floating/i;
 
     my $dt = Jifty::DateTime->new(%args);
 


More information about the Jifty-commit mailing list