Difference between revisions of "CmpTimes.pl"
From Organic Design wiki
m |
|||
Line 1: | Line 1: | ||
− | <perl> | + | <source lang="perl"> |
# For some reason there's no strtotime() equivalent in PERL's default install | # For some reason there's no strtotime() equivalent in PERL's default install | ||
# - this is a temp solution working for hh:mm.+d|dd.+mmm|mmmm.+yy|yyyy format{{perl}} | # - this is a temp solution working for hh:mm.+d|dd.+mmm|mmmm.+yy|yyyy format{{perl}} | ||
Line 15: | Line 15: | ||
return $times[1] > $times[0] ? -1 : $times[0] > $times[1]; | return $times[1] > $times[0] ? -1 : $times[0] > $times[1]; | ||
} | } | ||
− | </ | + | </source> |
[[Category:PERL]] | [[Category:PERL]] |
Latest revision as of 03:01, 23 April 2020
# For some reason there's no strtotime() equivalent in PERL's default install
# - this is a temp solution working for hh:mm.+d|dd.+mmm|mmmm.+yy|yyyy format{{perl}}
sub cmpTimes {
my @times = @_;
my $i = 0;
for (@times) {
for my $m ('jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec') {
s/$m\w*/$i%12+101/ie;
$i++;
}
s/^\D*(\d\d):(\d\d)\D+(\d+)\D+(\d\d\d)\D+(\d\d)\D*$/20$5$4$3$1$2/g;
s/^\D*(\d\d):(\d\d)\D+(\d+)\D+(\d\d\d)\D+(\d\d\d\d)\D*$/$5$4$3$1$2/g;
}
return $times[1] > $times[0] ? -1 : $times[0] > $times[1];
}