rather than write().
* sponge: Handle large data sizes by using a temp file rather than by
consuming arbitrary amounts of memory. Patch by Brock Noland.
+ * ts: Allow both -r and a format to be specified, to parse dates and output
+ in a specified format.
+ * ts: Fix bug in timezone regexp.
-- Joey Hess <joeyh@debian.org> Thu, 20 Mar 2008 12:56:42 -0400
formats are supported. Note that the Time::Duration and Date::Parse perl
modules are required for this mode to work.
+If both -r and a format is passed, the format existing timestamps are
+converted to the specified format.
+
=head1 ENVIRONMENT
The standard TZ environment variable controls what time zone dates
die $@ if $@;
}
+my $use_format=@ARGV;
my $format="%b %d %H:%M:%S";
$format=shift if @ARGV;
(?:\w\w\w,?\s+)? # (optional Day)
\d+\s+\w\w\w\s+\d\d+\s+\d\d:\d\d:\d\d
# 16 Jun 94 07:29:35
- (?:\s+\w\w\w|\s+-\d\d\d\d)?
+ (?:\s+\w\w\w|\s[+-]\d\d\d\d)?
# (optional timezone)
|
\w\w\w\s+\w\w\w\s+\d\d\s+\d\d:\d\d
# lastlog format
)\b
}{
- concise(ago(time - str2time($1), 2))
+ $use_format
+ ? strftime($format, localtime(str2time($1)))
+ : concise(ago(time - str2time($1), 2))
}exg;
print $_;