[Jifty-commit] r6558 - in jifty/trunk: lib/Jifty
Jifty commits
jifty-commit at lists.jifty.org
Wed Mar 4 18:27:52 EST 2009
Author: sartak
Date: Wed Mar 4 18:27:52 2009
New Revision: 6558
Modified:
jifty/trunk/ (props changed)
jifty/trunk/lib/Jifty/DateTime.pm
Log:
r80915 at onn: sartak | 2009-03-04 18:27:27 -0500
Enhance the API of get_tz_offset to allow an optional time zone
Modified: jifty/trunk/lib/Jifty/DateTime.pm
==============================================================================
--- jifty/trunk/lib/Jifty/DateTime.pm (original)
+++ jifty/trunk/lib/Jifty/DateTime.pm Wed Mar 4 18:27:52 2009
@@ -343,22 +343,27 @@
return 1;
}
-=head2 get_tz_offset [DateTime] -> String
+=head2 get_tz_offset
-Returns the offset for the current user's timezone. If there is no current
+Returns the offset for a time zone. If there is no current
user, or the current user's time zone is unset, then UTC will be used.
-The optional DateTime argument lets you calculate an offset for some time other
+The optional datetime argument lets you calculate an offset for some time other
than "right now".
=cut
sub get_tz_offset {
my $self = shift;
- my $dt = shift || DateTime->now();
+ my %args = (
+ datetime => DateTime->now,
+ time_zone => $self->current_user_has_timezone || 'UTC',
+ @_,
+ );
- $dt->set_time_zone( $self->current_user_has_timezone || 'UTC' );
+ my $dt = $args{datetime}->clone;
+ $dt->set_time_zone($args{time_zone});
return $dt->strftime("%z");
}
More information about the Jifty-commit
mailing list