Changeset 24216 for lang/perl/DateTime-Lite
- Timestamp:
- 11/19/08 11:19:30 (5 years ago)
- Location:
- lang/perl/DateTime-Lite/trunk
- Files:
-
- 4 modified
-
lib/DateTime/Lite.pm (modified) (5 diffs)
-
lib/DateTime/Lite/Locale.pm (modified) (2 diffs)
-
misc/locale/en_US.yaml (modified) (1 diff)
-
t/03components.t (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/DateTime-Lite/trunk/lib/DateTime/Lite.pm
r24215 r24216 6 6 use DateTime::Lite::Util; 7 7 use Scalar::Util qw(blessed); 8 use SelfLoader; 8 9 9 10 use constant INFINITY => (9 ** 9 ** 9); … … 29 30 30 31 # XXX Prime candidate for SelfLoading 31 sub ce_year { 32 my $year = $_[0]->{local_c}{year}; 33 return $year <= 0 ? $year - 1 : $year 34 } 32 # XXX 35 33 36 34 sub set_time_zone { … … 216 214 } 217 215 218 # XXX FIXME219 sub _offset_for_local_datetime { $_[0]->{tz}->offset_for_local_datetime( $_[0] ) }220 221 216 sub _calc_local_rd 222 217 { … … 239 234 240 235 # intentionally ignore leap seconds here 241 $self->_normalize_tai_seconds( $self->{local_rd_days}, $self->{local_rd_ 242 secs} ); 236 DateTime::Lite::Util::normalize_tai_seconds( $self->{local_rd_days}, $self->{local_rd_secs} ); 243 237 244 238 $self->{local_rd_secs} += $self->{offset_modifier}; … … 312 306 1; 313 307 308 __DATA__ 309 sub millisecond { _round( $_[0]->{rd_nanosecs} / 1000000 ) } 310 311 sub microsecond { _round( $_[0]->{rd_nanosecs} / 1000 ) } 312 313 sub _round 314 { 315 my $val = shift; 316 my $int = int $val; 317 318 return $val - $int >= 0.5 ? $int + 1 : $int; 319 } 320 321 sub ce_year { 322 my $year = $_[0]->{local_c}{year}; 323 return $year <= 0 ? $year - 1 : $year 324 } 325 sub month_0 { $_[0]->{local_c}{month} - 1 } 326 *mon_0 = \&month_0; 327 328 sub era_name { $_[0]->{locale}->era_wide->[ $_[0]->_era_index() ] } 329 330 sub era_abbr { $_[0]->{locale}->era_abbreviated->[ $_[0]->_era_index() ] } 331 # deprecated 332 *era = \&era_abbr; 333 334 sub _era_index { $_[0]->{local_c}{year} <= 0 ? 0 : 1 } 335 336 sub christian_era { $_[0]->ce_year > 0 ? 'AD' : 'BC' } 337 sub secular_era { $_[0]->ce_year > 0 ? 'CE' : 'BCE' } 338 339 sub year_with_era { (abs $_[0]->ce_year) . $_[0]->era_abbr } 340 sub year_with_christian_era { (abs $_[0]->ce_year) . $_[0]->christian_era } 341 sub year_with_secular_era { (abs $_[0]->ce_year) . $_[0]->secular_era } 342 343 344 sub month_name { $_[0]->{locale}->month_format_wide->[ $_[0]->month_0() ] } 345 346 sub month_abbr { $_[0]->{locale}->month_format_abbreviated->[ $_[0]->month_0() ] } 347 348 *day_of_month = \&day; 349 *mday = \&day; 350 sub weekday_of_month { use integer; ( ( $_[0]->day - 1 ) / 7 ) + 1 } 351 352 sub quarter_name { $_[0]->{locale}->quarter_format_wide->[ $_[0]->quarter_0() ] } 353 sub quarter_abbr { $_[0]->{locale}->quarter_format_abbreviated->[ $_[0]->quarter_0() ] } 354 355 sub quarter_0 { $_[0]->{local_c}{quarter} - 1 } 356 357 sub day_of_month_0 { $_[0]->{local_c}{day} - 1 } 358 *day_0 = \&day_of_month_0; 359 *mday_0 = \&day_of_month_0; 360 361 sub day_of_week { $_[0]->{local_c}{day_of_week} } 362 *wday = \&day_of_week; 363 *dow = \&day_of_week; 364 365 sub day_of_week_0 { $_[0]->{local_c}{day_of_week} - 1 } 366 *wday_0 = \&day_of_week_0; 367 *dow_0 = \&day_of_week_0; 368 sub hour_1 { $_[0]->{local_c}{hour} == 0 ? 24 : $_[0]->{local_c}{hour} } 369 370 sub hour_12 { my $h = $_[0]->hour % 12; return $h ? $h : 12 } 371 sub hour_12_0 { $_[0]->hour % 12 } 372 373 *min = \&minute; 374 375 *sec = \&second; 376 377 sub day_name { $_[0]->{locale}->day_format_wide->[ $_[0]->day_of_week_0() ] } 378 379 sub day_abbr { $_[0]->{locale}->day_format_abbreviated->[ $_[0]->day_of_week_0() ] } 380 381 sub day_of_quarter { $_[0]->{local_c}{day_of_quarter} } 382 *doq = \&day_of_quarter; 383 384 sub day_of_quarter_0 { $_[0]->day_of_quarter - 1 } 385 *doq_0 = \&day_of_quarter_0; 386 387 sub day_of_year { $_[0]->{local_c}{day_of_year} } 388 *doy = \&day_of_year; 389 390 sub day_of_year_0 { $_[0]->{local_c}{day_of_year} - 1 } 391 *doy_0 = \&day_of_year_0; 392 393 sub am_or_pm { $_[0]->{locale}->am_pm_abbreviated->[ $_[0]->hour() < 12 ? 0 : 1 ] } 394 395 # ISO says that the first week of a year is the first week containing 396 # a Thursday. Extending that says that the first week of the month is 397 # the first week containing a Thursday. ICU agrees. 398 # 399 # Algorithm supplied by Rick Measham, who doesn't understand how it 400 # works. Neither do I. Please feel free to explain this to me! 401 sub week_of_month 402 { 403 my $self = shift; 404 405 # Faster than cloning just to get the dow 406 my $first_wday_of_month = ( 8 - ( $self->day - $self->dow ) % 7 ) % 7; 407 $first_wday_of_month = 7 unless $first_wday_of_month; 408 409 my $wom = int( ( $self->day + $first_wday_of_month - 2 ) / 7 ); 410 return ( $first_wday_of_month <= 4 ) ? $wom + 1 : $wom; 411 } 412 413 sub ymd 414 { 415 my ( $self, $sep ) = @_; 416 $sep = '-' unless defined $sep; 417 418 return sprintf( "%0.4d%s%0.2d%s%0.2d", 419 $self->year, $sep, 420 $self->{local_c}{month}, $sep, 421 $self->{local_c}{day} ); 422 } 423 *date = \&ymd; 424 425 sub mdy 426 { 427 my ( $self, $sep ) = @_; 428 $sep = '-' unless defined $sep; 429 430 return sprintf( "%0.2d%s%0.2d%s%0.4d", 431 $self->{local_c}{month}, $sep, 432 $self->{local_c}{day}, $sep, 433 $self->year ); 434 } 435 436 sub dmy 437 { 438 my ( $self, $sep ) = @_; 439 $sep = '-' unless defined $sep; 440 441 return sprintf( "%0.2d%s%0.2d%s%0.4d", 442 $self->{local_c}{day}, $sep, 443 $self->{local_c}{month}, $sep, 444 $self->year ); 445 } 446 447 sub hms 448 { 449 my ( $self, $sep ) = @_; 450 $sep = ':' unless defined $sep; 451 452 return sprintf( "%0.2d%s%0.2d%s%0.2d", 453 $self->{local_c}{hour}, $sep, 454 $self->{local_c}{minute}, $sep, 455 $self->{local_c}{second} ); 456 } 457 # don't want to override CORE::time() 458 *DateTime::Lite::time = \&hms; 459 460 sub iso8601 { join 'T', $_[0]->ymd('-'), $_[0]->hms(':') } 461 *datetime = \&iso8601; 462 463 sub is_leap_year { DateTime::Lite::Util::is_leap_year( $_[0]->year ) } 464 465 sub time_zone { $_[0]->{tz} } 466 467 sub offset { $_[0]->{tz}->offset_for_datetime( $_[0] ) } 468 sub _offset_for_local_datetime { $_[0]->{tz}->offset_for_local_datetime( $_[0] ) } 469 470 sub is_dst { $_[0]->{tz}->is_dst_for_datetime( $_[0] ) } 471 472 sub time_zone_long_name { $_[0]->{tz}->name } 473 sub time_zone_short_name { $_[0]->{tz}->short_name_for_datetime( $_[0] ) } 474 475 sub locale { $_[0]->{locale} } 476 *language = \&locale; 477 478 479 314 480 __END__ -
lang/perl/DateTime-Lite/trunk/lib/DateTime/Lite/Locale.pm
r24134 r24216 23 23 } 24 24 25 sub new {26 my $class = shift;27 bless { scalar @_ == 1 ? %{$_[0]} : @_ }, $class;28 }29 30 25 sub load { 31 26 my ($class, $name) = @_; … … 39 34 } 40 35 36 use List::MoreUtils (); 37 38 BEGIN 39 { 40 foreach my $field ( qw( id en_complete_name native_complete_name 41 en_language en_script en_territory en_variant 42 native_language native_script native_territory native_variant 43 ) 44 ) 45 { 46 # remove leading 'en_' for method name 47 (my $meth_name = $field) =~ s/^en_//; 48 49 # also remove 'complete_' 50 $meth_name =~ s/complete_//; 51 52 no strict 'refs'; 53 *{$meth_name} = sub { $_[0]->{$field} }; 54 } 55 } 56 57 sub new 58 { 59 my $class = shift; 60 61 # By making the default format lengths part of the object's hash 62 # key, it allows them to be settable. 63 return bless { @_, 64 default_date_format_length => $class->_default_date_format_length(), 65 default_time_format_length => $class->_default_time_format_length(), 66 }, $class; 67 } 68 69 sub language_id { ( DateTime::Locale::_parse_id( $_[0]->id ) )[0] } 70 sub script_id { ( DateTime::Locale::_parse_id( $_[0]->id ) )[1] } 71 sub territory_id { ( DateTime::Locale::_parse_id( $_[0]->id ) )[2] } 72 sub variant_id { ( DateTime::Locale::_parse_id( $_[0]->id ) )[3] } 73 74 my @FormatLengths = qw( short medium long full ); 75 76 sub date_format_default 77 { 78 my $meth = 'date_format_' . $_[0]->default_date_format_length(); 79 $_[0]->$meth(); 80 } 81 82 sub date_formats 83 { 84 return 85 { map { my $meth = 'date_format_' . $_; 86 $_ => $_[0]->$meth() } @FormatLengths } 87 } 88 89 sub time_format_default 90 { 91 my $meth = 'time_format_' . $_[0]->default_time_format_length(); 92 $_[0]->$meth(); 93 } 94 95 sub time_formats 96 { 97 return 98 { map { my $meth = 'time_format_' . $_; 99 $_ => $_[0]->$meth() } @FormatLengths } 100 } 101 102 sub format_for 103 { 104 my $self = shift; 105 my $for = shift; 106 107 my $meth = '_format_for_' . $for; 108 109 return unless $self->can($meth); 110 111 return $self->$meth(); 112 } 113 114 sub available_formats 115 { 116 my $self = shift; 117 118 # The various parens seem to be necessary to force uniq() to see 119 # the caller's list context. Go figure. 120 my @uniq = List::MoreUtils::uniq( map { keys %{ $_->_available_formats() || {} } } 121 Class::ISA::self_and_super_path( ref $self ) ); 122 123 # Doing the sort in the same expression doesn't work under 5.6.x. 124 return sort @uniq; 125 } 126 127 # Just needed for the above method. 128 sub _available_formats { } 129 130 sub default_date_format_length { $_[0]->{default_date_format_length} } 131 132 sub set_default_date_format_length 133 { 134 my $self = shift; 135 my ($l) = validate_pos( @_, { regex => qr/^(?:full|long|medium|short)$/i } ); 136 137 $self->{default_date_format_length} = lc $l; 138 } 139 140 sub default_time_format_length { $_[0]->{default_time_format_length} } 141 142 sub set_default_time_format_length 143 { 144 my $self = shift; 145 my ($l) = validate_pos( @_, { regex => qr/^(?:full|long|medium|short)/i } ); 146 147 $self->{default_time_format_length} = lc $l; 148 } 149 150 for my $length ( qw( full long medium short ) ) 151 { 152 my $key = 'datetime_format_' . $length; 153 154 my $sub = 155 sub { my $self = shift; 156 157 return $self->{$key} if exists $self->{$key}; 158 159 my $date_meth = 'date_format_' . $length; 160 my $time_meth = 'time_format_' . $length; 161 162 return $self->{$key} = $self->_make_datetime_format( $date_meth, $time_meth ); 163 }; 164 165 no strict 'refs'; 166 *{$key} = $sub; 167 } 168 169 sub datetime_format_default 170 { 171 my $self = shift; 172 173 my $date_meth = 'date_format_' . $self->default_date_format_length(); 174 my $time_meth = 'time_format_' . $self->default_time_format_length(); 175 176 return $self->_make_datetime_format( $date_meth, $time_meth ); 177 } 178 179 sub _make_datetime_format 180 { 181 my $self = shift; 182 my $date_meth = shift; 183 my $time_meth = shift; 184 185 my $dt_format = $self->datetime_format(); 186 187 my $time = $self->$time_meth(); 188 my $date = $self->$date_meth(); 189 190 $dt_format =~ s/\{0\}/$time/g; 191 $dt_format =~ s/\{1\}/$date/g; 192 193 return $dt_format; 194 } 195 196 sub prefers_24_hour_time 197 { 198 my $self = shift; 199 200 return $self->{prefers_24_hour_time} 201 if exists $self->{prefers_24_hour_time}; 202 203 $self->{prefers_24_hour_time} = 204 $self->time_format_short() =~ /h|K/ ? 0 : 1; 205 } 206 207 sub date_before_time 208 { 209 my $self = shift; 210 211 my $dt_format = $self->datetime_format(); 212 213 return $dt_format =~ /\{1\}.*\{0\}/ ? 1 : 0; 214 } 215 216 sub date_parts_order 217 { 218 my $self = shift; 219 220 my $short = $self->date_format_short(); 221 222 $short =~ tr{dmyDMY}{}cd; 223 $short =~ tr{dmyDMY}{dmydmy}s; 224 225 return $short; 226 } 227 228 sub full_date_format { $_[0]->_convert_to_strftime( $_[0]->date_format_full() ) } 229 sub long_date_format { $_[0]->_convert_to_strftime( $_[0]->date_format_long() ) } 230 sub medium_date_format { $_[0]->_convert_to_strftime( $_[0]->date_format_medium() ) } 231 sub short_date_format { $_[0]->_convert_to_strftime( $_[0]->date_format_short() ) } 232 sub default_date_format { $_[0]->_convert_to_strftime( $_[0]->date_format_default() ) } 233 234 sub full_time_format { $_[0]->_convert_to_strftime( $_[0]->time_format_full() ) } 235 sub long_time_format { $_[0]->_convert_to_strftime( $_[0]->time_format_long() ) } 236 sub medium_time_format { $_[0]->_convert_to_strftime( $_[0]->time_format_medium() ) } 237 sub short_time_format { $_[0]->_convert_to_strftime( $_[0]->time_format_short() ) } 238 sub default_time_format { $_[0]->_convert_to_strftime( $_[0]->time_format_default() ) } 239 240 sub full_datetime_format { $_[0]->_convert_to_strftime( $_[0]->datetime_format_full() ) } 241 sub long_datetime_format { $_[0]->_convert_to_strftime( $_[0]->datetime_format_long() ) } 242 sub medium_datetime_format { $_[0]->_convert_to_strftime( $_[0]->datetime_format_medium() ) } 243 sub short_datetime_format { $_[0]->_convert_to_strftime( $_[0]->datetime_format_short() ) } 244 sub default_datetime_format { $_[0]->_convert_to_strftime( $_[0]->datetime_format_default() ) } 245 246 # Older versions of DateTime.pm will not pass in the $cldr_ok flag, so 247 # we will give them the converted-to-strftime pattern (bugs and all). 248 sub _convert_to_strftime 249 { 250 my $self = shift; 251 my $pattern = shift; 252 my $cldr_ok = shift; 253 254 return $pattern if $cldr_ok; 255 256 return $self->{_converted_patterns}{$pattern} 257 if exists $self->{_converted_patterns}{$pattern}; 258 259 return $self->{_converted_patterns}{$pattern} = $self->_cldr_to_strftime($pattern); 260 } 261 262 { 263 my @JavaPatterns = 264 ( qr/G/ => '{era}', 265 qr/yyyy/ => '{ce_year}', 266 qr/y/ => 'y', 267 qr/u/ => 'Y', 268 qr/MMMM/ => 'B', 269 qr/MMM/ => 'b', 270 qr/MM/ => 'm', 271 qr/M/ => '{month}', 272 qr/dd/ => 'd', 273 qr/d/ => '{day}', 274 qr/hh/ => 'l', 275 qr/h/ => '{hour_12}', 276 qr/HH/ => 'H', 277 qr/H/ => '{hour}', 278 qr/mm/ => 'M', 279 qr/m/ => '{minute}', 280 qr/ss/ => 'S', 281 qr/s/ => '{second}', 282 qr/S/ => 'N', 283 qr/EEEE/ => 'A', 284 qr/E/ => 'a', 285 qr/D/ => 'j', 286 qr/F/ => '{weekday_of_month}', 287 qr/w/ => 'V', 288 qr/W/ => '{week_month}', 289 qr/a/ => 'p', 290 qr/k/ => '{hour_1}', 291 qr/K/ => '{hour_12_0}', 292 qr/z/ => '{time_zone_long_name}', 293 ); 294 295 sub _cldr_to_strftime 296 { 297 shift; 298 my $simple = shift; 299 300 $simple =~ 301 s/(G+|y+|u+|M+|d+|h+|H+|m+|s+|S+|E+|D+|F+|w+|W+|a+|k+|K+|z+)|'((?:[^']|'')*)'/ 302 $2 ? _stringify($2) : $1 ? _convert($1) : "'"/eg; 303 304 return $simple; 305 } 306 307 sub _convert 308 { 309 my $simple = shift; 310 311 for ( my $x = 0; $x < @JavaPatterns; $x += 2 ) 312 { 313 return '%' . $JavaPatterns[ $x + 1 ] if $simple =~ /$JavaPatterns[$x]/; 314 } 315 316 die "**Dont know $simple***"; 317 } 318 319 sub _stringify 320 { 321 my $string = shift; 322 323 $string =~ s/%(?:[^%])/%%/g; 324 $string =~ s/\'\'/\'/g; 325 326 return $string; 327 } 328 } 329 330 # end backwards compat 331 332 sub STORABLE_freeze 333 { 334 my $self = shift; 335 my $cloning = shift; 336 337 return if $cloning; 338 339 return $self->id(); 340 } 341 342 sub STORABLE_thaw 343 { 344 my $self = shift; 345 my $cloning = shift; 346 my $serialized = shift; 347 348 my $obj = DateTime::Locale->load( $serialized ); 349 350 %$self = %$obj; 351 352 return $self; 353 } 354 355 foreach my $field qw( 356 am_pm_abbreviated 357 date_format_full 358 date_format_long 359 date_format_medium 360 date_format_short 361 datetime_format 362 day_format_abbreviated 363 day_format_narrow 364 day_format_wide 365 day_stand_alone_abbreviated 366 day_stand_alone_narrow 367 day_stand_alone_wide 368 era_abbreviated 369 era_narrow 370 era_wide 371 first_day_of_week 372 month_format_abbreviated 373 month_format_narrow 374 month_format_wide 375 month_stand_alone_abbreviated 376 month_stand_alone_narrow 377 month_stand_alone_wide 378 quarter_format_abbreviated 379 quarter_format_narrow 380 quarter_format_wide 381 quarter_stand_alone_abbreviated 382 quarter_stand_alone_narrow 383 quarter_stand_alone_wide 384 time_format_full 385 time_format_long 386 time_format_medium 387 time_format_short 388 _default_date_format_length 389 _default_time_format_length 390 _format_for_Hm 391 _format_for_M 392 _format_for_MEd 393 _format_for_MMM 394 _format_for_MMMEd 395 _format_for_MMMMEd 396 _format_for_MMMMd 397 _format_for_MMMd 398 _format_for_Md 399 _format_for_d 400 _format_for_ms 401 _format_for_y 402 _format_for_yM 403 _format_for_yMEd 404 _format_for_yMMM 405 _format_for_yMMMEd 406 _format_for_yMMMM 407 _format_for_yQ 408 _format_for_yQQQ 409 ) { 410 no strict 'refs'; 411 *{$field} = sub { $_[0]->{$field} } 412 } 413 414 41 415 1; -
lang/perl/DateTime-Lite/trunk/misc/locale/en_US.yaml
r24134 r24216 1 1 name: en_US 2 am_pm_abbreviated: [ "AM", "PM" ] 3 date_format_full: "EEEE, MMMM d, yyyy" 4 date_format_long: "MMMM d, yyyy" 5 date_format_medium: "MMM d, yyyy" 6 date_format_short: "M/d/yy" 7 datetime_format: "{1} {0}" 8 day_format_abbreviated: [ "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" ] 9 day_format_narrow: [ "M", "T", "W", "T", "F", "S", "S" ] 10 day_format_wide: [ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ] 11 12 day_stand_alone_abbreviated: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ] 13 day_stand_alone_narrow: [ "M", "T", "W", "T", "F", "S", "S" ] 14 15 day_stand_alone_wide: [ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ] 16 era_abbreviated: [ "BC", "AD" ] 17 era_narrow: [ "B", "A" ] 18 era_wide: [ "Before Christ", "Anno Domini" ] 19 first_day_of_week: 1 20 month_format_abbreviated: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ] 21 22 month_format_narrow: [ "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D" ] 23 month_format_wide: [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ] 24 month_stand_alone_abbreviated: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ] 25 month_stand_alone_narrow: [ "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D" ] 26 27 month_stand_alone_wide: [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ] 28 quarter_format_abbreviated: [ "Q1", "Q2", "Q3", "Q4" ] 29 quarter_format_narrow: [ "1", "2", "3", "4" ] 30 quarter_format_wide: [ "1st quarter", "2nd quarter", "3rd quarter", "4th quarter" ] 31 32 quarter_stand_alone_abbreviated : [ "Q1", "Q2", "Q3", "Q4" ] 33 quarter_stand_alone_narrow: [ "1", "2", "3", "4" ] 34 35 quarter_stand_alone_wide : [ "1st quarter", "2nd quarter", "3rd quarter", "4th quarter" ] 36 time_format_full: "h:mm:ss a v" 37 time_format_long: "h:mm:ss a z" 38 time_format_medium: "h:mm:ss a" 39 time_format_short: "h:mm a" 40 _format_for_Hm: "HH:mm" 41 _format_for_Hms: "HH:mm:ss" 42 _format_for_M: "L" 43 _format_for_MEd: "E, M/d" 44 _format_for_MMM: "LLL" 45 _format_for_MMMEd: "E, MMM d" 46 _format_for_MMMMEd: "E, MMMM d" 47 _format_for_MMMMd: "MMMM d" 48 _format_for_MMMd: "MMM d" 49 _format_for_Md: "M/d" 50 _format_for_d: "d" 51 _format_for_hm: "h:mm a" 52 _format_for_ms: "mm:ss" 53 _format_for_y: "yyyy" 54 _format_for_yM: "M/yyyy" 55 _format_for_yMEd: "EEE, M/d/yyyy" 56 _format_for_yMMM: "MMM yyyy" 57 _format_for_yMMMEd: "EEE, MMM d, yyyy" 58 _format_for_yMMMM: "MMMM yyyy" 59 _format_for_yQ: "Q yyyy" 60 _format_for_yQQQ: "QQQ yyyy" 61 _available_formats: 62 "Hm": "HH:mm" 63 "Hms": "HH:mm:ss" 64 "M": "L" 65 "MEd": "E, M/d" 66 "MMM": "LLL" 67 "MMMEd": "E, MMM d" 68 "MMMMEd": "E, MMMM d" 69 "MMMMd": "MMMM d" 70 "MMMd": "MMM d" 71 "Md": "M/d" 72 "d": "d" 73 "hm": "h:mm a" 74 "ms": "mm:ss" 75 "y": "yyyy" 76 "yM": "M/yyyy" 77 "yMEd": "EEE, M/d/yyyy" 78 "yMMM": "MMM yyyy" 79 "yMMMEd": "EEE, MMM d, yyyy" 80 "yMMMM": "MMMM yyyy" 81 "yQ": "Q yyyy" 82 "yQQQ": "QQQ yyyy" 83 -
lang/perl/DateTime-Lite/trunk/t/03components.t
r24134 r24216 143 143 is( $dt0->year_with_secular_era, '1CE', 'year_with_secular_era is 1CE' ); 144 144 145 SKIP: { 146 skip "arithmetic not yet implemented", 8; 147 145 148 $dt0->subtract( years => 1 ); 146 149 … … 153 156 is( $dt0->secular_era, 'BCE', 'secular_era is BCE' ); 154 157 is( $dt0->year_with_secular_era, '1BCE', 'year_with_secular_era is 1BCE' ); 158 } 155 159 } 156 160 … … 160 164 is( $dt_neg->ce_year, -11, "year -10 is ce_year -11" ); 161 165 166 SKIP: { 167 skip "duration not yet implemented", 2; 162 168 my $dt1 = $dt_neg + DateTime::Lite::Duration->new( years => 10 ); 163 169 is( $dt1->year, 0, "year is 0 after adding ten years to year -10" ); 164 170 is( $dt1->ce_year, -1, "ce_year is -1 after adding ten years to year -10" ); 171 } 165 172 } 166 173
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)