@@ -23,6 +23,9 @@ sub init {
2323 my $options = {
2424 ' key|k=s' => sub { $this -> {' KEYS' }-> add_groups($_ [1]) },
2525 ' format|f=s' => \($this -> {' FORMAT' }),
26+ ' iso|iso8601' => sub { $this -> {' FORMAT' } = ' %FT%T%z' },
27+ ' epoch' => sub { $this -> {' FORMAT' } = ' %s' },
28+ ' pretty' => sub { $this -> {' FORMAT' } = ' %c' },
2629 ' dmy' => \($this -> {' UK' }),
2730 ' past' => \($this -> {' PAST' }),
2831 ' future' => \($this -> {' FUTURE' }),
@@ -34,8 +37,11 @@ sub init {
3437 };
3538 $this -> parse_options($args , $options );
3639
37- die " --key is required\n " unless $this -> {' KEYS' }-> has_any_group;
38- die " --format is required\n " unless defined $this -> {' FORMAT' };
40+ die " --key is required\n "
41+ unless $this -> {' KEYS' }-> has_any_group;
42+
43+ die " --format (or one of --iso, --epoch, or --pretty) is required\n "
44+ unless defined $this -> {' FORMAT' };
3945}
4046
4147sub accept_record {
@@ -77,6 +83,9 @@ sub usage {
7783 my $options = [
7884 [' key|-k <keys>' , ' Datetime keys to parse and reformat; may be a key spec or key group. Required.' ],
7985 [' format|-f <strftime>' , ' Format string for strftime(3). Required.' ],
86+ [' iso|--iso8601' , ' Output datetimes as an ISO 8601 timestamp (equivalent to -f %FT%T%z)' ],
87+ [' epoch' , ' Output datetimes as the number of seconds since the epoch (equivalent to -f %s)' ],
88+ [' pretty' , ' Output datetimes in the locale-preferred format (equivalent to -f %c)' ],
8089 [' dmy' , ' Assume dd/mm (UK-style) instead of mm/dd (US-style)' ],
8190 [' past' , ' Assume ambiguous years and days of the week are in the past' ],
8291 [' future' , ' Assume ambiguous years and days of the week are in the future' ],
0 commit comments