diff options
author | Matthew Somerville <matthew@mysociety.org> | 2011-06-24 17:45:58 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2011-06-28 15:01:03 +0100 |
commit | 85a3050d6e5e0f7f0bd9d3c827533f5d84d0b396 (patch) | |
tree | 542f579cb076f7b70d30848afe92313450d964e4 /perllib/Utils.pm | |
parent | 9c662a2c3ba48a75e114ba4cff9826438441a949 (diff) |
Sort problems, and have a map, maybe.
Diffstat (limited to 'perllib/Utils.pm')
-rw-r--r-- | perllib/Utils.pm | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/perllib/Utils.pm b/perllib/Utils.pm index 44234607f..39c251876 100644 --- a/perllib/Utils.pm +++ b/perllib/Utils.pm @@ -210,20 +210,25 @@ sub cleanup_text { } sub prettify_epoch { - my ($s, $short) = @_; + my ( $s, $type ) = @_; + $type = 'short' if $type eq '1'; + my @s = localtime($s); - my $tt = strftime('%H:%M', @s); + my $tt = ''; + $tt = strftime('%H:%M', @s) unless $type eq 'date'; my @t = localtime(); if (strftime('%Y%m%d', @s) eq strftime('%Y%m%d', @t)) { - $tt = "$tt " . _('today'); - } elsif (strftime('%Y %U', @s) eq strftime('%Y %U', @t)) { - $tt = "$tt, " . decode_utf8(strftime('%A', @s)); - } elsif ($short) { - $tt = "$tt, " . decode_utf8(strftime('%e %b %Y', @s)); + return "$tt " . _('today'); + } + $tt .= ', ' unless $type eq 'date'; + if (strftime('%Y %U', @s) eq strftime('%Y %U', @t)) { + $tt .= decode_utf8(strftime('%A', @s)); + } elsif ($type eq 'short') { + $tt .= decode_utf8(strftime('%e %b %Y', @s)); } elsif (strftime('%Y', @s) eq strftime('%Y', @t)) { - $tt = "$tt, " . decode_utf8(strftime('%A %e %B %Y', @s)); + $tt .= decode_utf8(strftime('%A %e %B %Y', @s)); } else { - $tt = "$tt, " . decode_utf8(strftime('%a %e %B %Y', @s)); + $tt .= decode_utf8(strftime('%a %e %B %Y', @s)); } return $tt; } |