Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision d16e003e

Von Moritz Bunkus vor mehr als 10 Jahren hinzugefügt

  • ID d16e003e400bfad9e45acbf1fd0cee70dd68b848
  • Vorgänger df2fba09
  • Nachfolger 646cb2aa

Locale::format_date_object: explizites Setzen der Formate; Millisekunden als neues Format

…und dazu Tests.

Unterschiede anzeigen:

SL/Locale.pm
394 394
sub format_date_object {
395 395
  my ($self, $datetime, %params)    = @_;
396 396

  
397
  my $format             =  $::myconfig{dateformat} || 'yyyy-mm-dd';
397
  my $format             =   $params{dateformat}   || $::myconfig{dateformat}   || 'yyyy-mm-dd';
398
  my $num_separator      =  ($params{numberformat} || $::myconfig{numberformat} || '1,000.00') =~ m{,\d+$} ? ',' : '.';
398 399
  $format                =~ s/yy(?:yy)?/\%Y/;
399 400
  $format                =~ s/mm/\%m/;
400 401
  $format                =~ s/dd/\%d/;
......
402 403
  my $precision          =  $params{precision} || 'day';
403 404
  $precision             =~ s/s$//;
404 405
  my %precision_spec_map = (
405
    second => '%H:%M:%S',
406
    minute => '%H:%M',
407
    hour   => '%H',
406
    millisecond => '%H:%M:%S' . $num_separator . '%3N',
407
    second      => '%H:%M:%S',
408
    minute      => '%H:%M',
409
    hour        => '%H',
408 410
  );
409 411

  
410 412
  $format .= ' ' . $precision_spec_map{$precision} if $precision_spec_map{$precision};
......
609 611

  
610 612
Add hour:minute:second to the date.
611 613

  
614
=item * C<millisecond>
615

  
616
Add hour:minute:second.millisecond to the date. The decimal separator
617
is derived from the number format.
618

  
619
=item * C<numberformat>
620

  
621
The number format to use, e.g. C<1,000.00>. If unset the user's
622
current number format is used.
623

  
624
=item * C<dateformat>
625

  
626
The date format to use, e.g. C<mm/dd/yy>. If unset the user's current
627
date format is used.
628

  
612 629
=back
613 630

  
614 631
=item C<get_local_time_zone>

Auch abrufbar als: Unified diff