[Jifty-commit] r4020 - in jifty/trunk: lib/Jifty

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Fri Aug 31 17:30:44 EDT 2007


Author: sartak
Date: Fri Aug 31 17:30:44 2007
New Revision: 4020

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

Log:
 r40432 at onn:  sartak | 2007-08-31 17:30:24 -0400
 In Jifty::DateTime->new, set the timezone to floating if it looks like just a date


Modified: jifty/trunk/lib/Jifty/DateTime.pm
==============================================================================
--- jifty/trunk/lib/Jifty/DateTime.pm	(original)
+++ jifty/trunk/lib/Jifty/DateTime.pm	Fri Aug 31 17:30:44 2007
@@ -30,9 +30,10 @@
 
 =head2 new ARGS
 
-See L<DateTime/new>.  After calling that method, set this object's
+See L<DateTime/new>. If we get what appears to be a date, then we
+keep this in the floating datetime. Otherwise, set this object's
 timezone to the current user's time zone, if the current user has a
-method called C<time_zone>.
+method called C<time_zone>.  
 
 =cut
 
@@ -41,13 +42,19 @@
     my %args  = (@_);
     my $self  = $class->SUPER::new(%args);
 
-    # Unless the user has explicitly said they want a floating time,
-    # we want to convert to the end-user's timezone.  This is
-    # complicated by the fact that DateTime auto-appends
-    if (!$args{time_zone} and my $tz = $self->current_user_has_timezone) {
-        $self->set_time_zone("UTC");
-        $self->set_time_zone( $tz );
+    if ($self->hour || $self->minute || $self->second) {
+        # Unless the user has explicitly said they want a floating time,
+        # we want to convert to the end-user's timezone.  This is
+        # complicated by the fact that DateTime auto-appends
+        if (!$args{time_zone} and my $tz = $self->current_user_has_timezone) {
+            $self->set_time_zone("UTC");
+            $self->set_time_zone( $tz );
+        }
     }
+    else {
+        $self->set_time_zone("floating");
+    }
+
     return $self;
 }
 


More information about the Jifty-commit mailing list