[Rt-commit] rt branch, datetime_locale_fixes, created. rt-3.8.5-289-g8139f0b
Kevin Falcone
falcone at bestpractical.com
Fri Oct 9 17:52:15 EDT 2009
The branch, datetime_locale_fixes has been created
at 8139f0b974cf17305f1f0b88b1791a67f8196893 (commit)
- Log -----------------------------------------------------------------
commit 8139f0b974cf17305f1f0b88b1791a67f8196893
Author: Kevin Falcone <falcone at bestpractical.com>
Date: Fri Oct 9 17:50:34 2009 -0400
Convert to the cldr methods
DateTime::Locale 0.44 declared the strftime methods deprecated
but there is a but in 0.44 in the cldr->strftime conversion
diff --git a/lib/RT/Date.pm b/lib/RT/Date.pm
index d4bfe8c..e4391e6 100755
--- a/lib/RT/Date.pm
+++ b/lib/RT/Date.pm
@@ -641,8 +641,8 @@ sub LocalizedDateTime
my %args = ( Date => 1,
Time => 1,
Timezone => '',
- DateFormat => 'full_date_format',
- TimeFormat => 'medium_time_format',
+ DateFormat => 'date_format_full',
+ TimeFormat => 'time_format_medium',
AbbrDay => 1,
AbbrMonth => 1,
@_,
@@ -658,8 +658,8 @@ sub LocalizedDateTime
my $formatter = DateTime::Locale->load($lang);
$date_format = $formatter->$date_format;
$time_format = $formatter->$time_format;
- $date_format =~ s/\%A/\%a/g if ( $args{'AbbrDay'} );
- $date_format =~ s/\%B/\%b/g if ( $args{'AbbrMonth'} );
+ $date_format =~ s/EEEE/EEE/g if ( $args{'AbbrDay'} );
+ $date_format =~ s/MMMM/MMM/g if ( $args{'AbbrMonth'} );
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$ydaym,$isdst,$offset) =
$self->Localtime($args{'Timezone'});
@@ -680,11 +680,11 @@ sub LocalizedDateTime
);
if ( $args{'Date'} && !$args{'Time'} ) {
- return $dt->strftime($date_format);
+ return $dt->format_cldr($date_format);
} elsif ( !$args{'Date'} && $args{'Time'} ) {
- return $dt->strftime($time_format);
+ return $dt->format_cldr($time_format);
} else {
- return $dt->strftime($date_format) . " " . $dt->strftime($time_format);
+ return $dt->format_cldr($date_format) . " " . $dt->format_cldr($time_format);
}
}
diff --git a/t/api/date.t b/t/api/date.t
index 3eb29fd..7d0e853 100644
--- a/t/api/date.t
+++ b/t/api/date.t
@@ -167,10 +167,10 @@ my $current_user;
is($date->LocalizedDateTime(AbbrMonth => 0),
'Thu, January 1, 1970 12:00:00 AM',
"LocalizedDateTime format without abbreviation of month") if ( $localized_datetime_tests );
- is($date->LocalizedDateTime(DateFormat => 'short_date_format'),
+ is($date->LocalizedDateTime(DateFormat => 'date_format_short'),
'1/1/70 12:00:00 AM',
"LocalizedDateTime format with non default DateFormat") if ( $localized_datetime_tests );
- is($date->LocalizedDateTime(TimeFormat => 'short_time_format'),
+ is($date->LocalizedDateTime(TimeFormat => 'time_format_short'),
'Thu, Jan 1, 1970 12:00 AM',
"LocalizedDateTime format with non default TimeFormat") if ( $localized_datetime_tests );
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list