in reply to Re: ASCII chart that displays jobs that are running and jobs that are queued for a day
in thread ASCII chart that displays jobs that are running and jobs that are queued for a day
Horrendous. Try this:
use Lingua::EN::Numbers::Ordinate; my @standard_formats = ( 'dd/mm/yyyy - HH:mm:ss', # -1: 15/01/2000 - 03:15:30 'MM/dd/yy, HH:mm:ss', # 0: 01/15/00, 15:15:30 'dd.MM.yy, HH:mm:ss', # 1: 15.01.00, 15:15:30 'dd.MM.yyyy, HH:mm:ss', # 2: 15.01.2000, 15:15:30 'MMM D, yyyy, h:mm tt', # 3: Jan 15th, 2000, 3:15pm 'd. MMM yyyy, hh:mm', # 4: 15. Jan 2000, 15:15 'MM/dd/yy, h:mm tt', # 5: 01/15/00, 3:15pm 'ddd, d MMMM, yyyy', # 6: Sunday, 15 January, 2000 'yyyyMMdd', # 7 'yyyyMM', # 8 ); my @months = qw( January February March April May June July August September October November December ); my @wdays = qw( Sunday Monday Tuesday Wednesday Thursday Friday Saturday ); sub d2($) { sprintf '%02d', $_[0] } sub format_date { my( $date, $date_format ) = @_; # either could be undef defined $date or $date = get_date(); defined $date_format or $date_format = get_date_format(); # from user data, cfg file $date_format++; # since they start at -1 defined $standard_formats[$date_format] or $date_format = 0; # default my( $sec, $min, $hour, $mday, $mon, $year, $wday ) = localtime $da +te; my $month = $months[$mon]; my $weekday = $wdays[$wday]; $mon++; $year += 1900; # set up the substitutions: my %v; $v{'d'} = $mday; $v{'dd'} = d2 $v{'d'}; $v{'dddd'} = $weekday; $v{'ddd'} = substr $v{'dddd'}, 0, 3; $v{'D'} = ordinate($v{'d'}); $v{'M'} = $mon; $v{'MM'} = d2 $v{'M'}; $v{'MMMM'} = $month; $v{'MMM'} = substr $v{'MMMM'}, 0, 3; $v{'y'} = $year % 100; $v{'yy'} = d2 $v{'y'}; $v{'yyyy'} = $year; $v{'H'} = $hour; $v{'HH'} = d2 $v{'H'}; $v{'h'} = $hour % 12; $v{'hh'} = d2 $v{'h'}; $v{'m'} = $min; $v{'mm'} = d2 $v{'m'}; $v{'s'} = $sec; $v{'ss'} = d2 $v{'s'}; $v{'t'} = $hour>=12?'P':'A'; $v{'tt'} = $v{'t'}.'M'; my $tf = $standard_formats[$date_format]; # do the substitutions: $tf =~ s/\b([dDMyHhmst]+)\b/ $v{$1} || $1 /ge; # this seems to be sflex's preference: $tf =~ s/ ([AP]M)/\L$1/; $tf }
|
|---|