[Jifty-commit] r6547 - in jifty/trunk: . lib/Jifty
Jifty commits
jifty-commit at lists.jifty.org
Tue Mar 3 17:44:37 EST 2009
Author: sartak
Date: Tue Mar 3 17:44:37 2009
New Revision: 6547
Modified:
jifty/trunk/ (props changed)
jifty/trunk/lib/Jifty/DateTime.pm
jifty/trunk/lib/Jifty/Filter/DateTime.pm
Log:
r80827 at onn: sartak | 2009-03-03 17:44:30 -0500
Simplify the logic of date handling a bunch
Modified: jifty/trunk/lib/Jifty/DateTime.pm
==============================================================================
--- jifty/trunk/lib/Jifty/DateTime.pm (original)
+++ jifty/trunk/lib/Jifty/DateTime.pm Tue Mar 3 17:44:37 2009
@@ -58,40 +58,21 @@
my $class = shift;
my %args = @_;
- my $replace_tz = delete $args{_replace_time_zone};
my $current_user = delete $args{current_user};
my $self = $class->SUPER::new(%args);
- $self->current_user($current_user);
-
- # XXX What if they really mean midnight offset by time zone?
+ my $is_date = $self->hms eq '00:00:00'
+ && $self->time_zone->name eq 'floating';
- # this behavior is (sadly!) consistent with
- # DateTime->truncate(to => 'day') and Jifty::DateTime::new_from_string
- # suggestions for improvement are very welcome
-
- # Do not bother with time zones unless time is used, we assume that
- # 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 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} || $replace_tz) {
- if (my $tz = $self->current_user_has_timezone) {
- # if we just set $tz directly, then it won't convert properly
- # from the Floating time zone.
- $self->set_time_zone("UTC");
-
- $self->set_time_zone( $tz );
- }
- }
- }
+ $self->current_user($current_user);
+ $self->time_zone($args{time_zone}) if $args{time_zone};
- # No time, just use the floating time zone
- else {
- $self->set_time_zone("floating");
+ if ($is_date) {
+ $self->hour(0);
+ $self->minute(0);
+ $self->second(0);
+ $self->set_time_zone('floating');
}
return $self;
Modified: jifty/trunk/lib/Jifty/Filter/DateTime.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Filter/DateTime.pm (original)
+++ jifty/trunk/lib/Jifty/Filter/DateTime.pm Tue Mar 3 17:44:37 2009
@@ -58,11 +58,6 @@
$args{$_} = $$value_ref->$_ if(defined($$value_ref->$_));
}
- # 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 $class = Jifty->app_class('DateTime');
$class = 'Jifty::DateTime' unless $class->can('new');
my $dt = $class->new(%args);
More information about the Jifty-commit
mailing list