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

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Tue Jan 8 00:57:19 EST 2008


Author: alexmv
Date: Tue Jan  8 00:57:18 2008
New Revision: 4800

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

Log:
 r26465 at zoq-fot-pik:  chmrr | 2008-01-08 00:55:56 -0500
  * Force time zone update on current_user change


Modified: jifty/trunk/lib/Jifty/DateTime.pm
==============================================================================
--- jifty/trunk/lib/Jifty/DateTime.pm	(original)
+++ jifty/trunk/lib/Jifty/DateTime.pm	Tue Jan  8 00:57:18 2008
@@ -22,11 +22,15 @@
 
 =head1 DESCRIPTION
 
-Jifty natively stores timestamps in the database in GMT.  Dates are stored
-without timezone. This class loads and parses dates and sets them
-into the proper timezone.
-
-To use this DateTime class to it's fullest ability, you'll need to add a C<time_zone> method to your application's user object class. This is the class returned by L<Jifty::CurrentUser/user_object>. It must return a value valid for using as an argument to L<DateTime>'s C<set_time_zone()> method.
+Jifty natively stores timestamps in the database in GMT.  Dates are
+stored without timezone. This class loads and parses dates and sets
+them into the proper timezone.
+
+To use this DateTime class to it's fullest ability, you'll need to add
+a C<time_zone> method to your application's user object class. This is
+the class returned by L<Jifty::CurrentUser/user_object>. It must
+return a value valid for using as an argument to L<DateTime>'s
+C<set_time_zone()> method.
 
 =cut
 
@@ -126,9 +130,26 @@
     return $self;
 }
 
+=head2 current_user [CURRENTUSER]
+
+When setting the current user, update the timezone appropriately.
+
+=cut
+
+sub current_user {
+    my $self = shift;
+    return $self->SUPER::current_user unless @_;
+    my $ret = $self->SUPER::current_user(@_);
+    $self->set_current_user_timezone();
+    return $ret;
+}
+
 =head2 current_user_has_timezone
 
-Return timezone if the current user has one. This is determined by checking to see if the current user has a user object. If it has a user object, then it checks to see if that user object has a C<time_zone> method and uses that to determine the value.
+Return timezone if the current user has one. This is determined by
+checking to see if the current user has a user object. If it has a
+user object, then it checks to see if that user object has a
+C<time_zone> method and uses that to determine the value.
 
 =cut
 
@@ -171,7 +192,9 @@
 it in the floating timezone, otherwise, set it to the current user's
 timezone.
 
-As of this writing, this uses L<Date::Manip> along with some internal hacks to alter the way L<Date::Manip> normally interprets week day names. This may change in the future.
+As of this writing, this uses L<Date::Manip> along with some internal
+hacks to alter the way L<Date::Manip> normally interprets week day
+names. This may change in the future.
 
 =cut
 
@@ -288,9 +311,14 @@
 
 =head1 WHY?
 
-There are other ways to do some of these things and some of the decisions here may seem arbitrary, particularly if you read the code. They are.
-
-These things are valuable to applications built by Best Practical Solutions, so it's here. If you disagree with the policy or need to do it differently, then you probably need to implement something yourself using a DateTime::Format::* class or your own code. 
+There are other ways to do some of these things and some of the
+decisions here may seem arbitrary, particularly if you read the
+code. They are.
+
+These things are valuable to applications built by Best Practical
+Solutions, so it's here. If you disagree with the policy or need to do
+it differently, then you probably need to implement something yourself
+using a DateTime::Format::* class or your own code.
 
 Parts may be cleaned up and the API cleared up a bit more in the future.
 


More information about the Jifty-commit mailing list