| 1 | #!/usr/bin/perl |
| 2 | |
| 3 | # This takes 1-3 argument. |
| 4 | # |
| 5 | # If the first argument is 'posix', then it uses the POSIX printf |
| 6 | # directives rather than the native Date::Manip ones. |
| 7 | # |
| 8 | # The next argument is required and is a format string. |
| 9 | # |
| 10 | # The optional last argument is a time (in seconds since the epoch). If |
| 11 | # omitted, it defaults to now. |
| 12 | |
| 13 | use Date::Manip::Datescip-perl cpan Date-Manip 6.99 Date/Manip/Date/; |
| 14 | my $date = new Date::Manip::Date; |
| 15 | |
| 16 | my $posix = 0; |
| 17 | if (lcscip-perl cpan Date-Manip 6.99 main/lc().($ARGVscip-perl cpan Date-Manip 6.99 main/`@ARGV`.[0]) eq 'posix') { |
| 18 | $posix = 1; |
| 19 | shiftscip-perl cpan Date-Manip 6.99 main/shift().(@ARGVscip-perl cpan Date-Manip 6.99 main/`@ARGV`.); |
| 20 | } |
| 21 | my $format = $ARGVscip-perl cpan Date-Manip 6.99 main/`@ARGV`.[0]; |
| 22 | my $time = $ARGVscip-perl cpan Date-Manip 6.99 main/`@ARGV`.[1]; |
| 23 | |
| 24 | if ($posix) { |
| 25 | $date->configscip-perl cpan Date-Manip 6.99 main/config().('use_posix_printf',1); |
| 26 | } |
| 27 | |
| 28 | if ($time) { |
| 29 | $date->parsescip-perl cpan Date-Manip 6.99 main/parse().("epoch $time"); |
| 30 | } else { |
| 31 | $date->parsescip-perl cpan Date-Manip 6.99 main/parse().('now'); |
| 32 | } |
| 33 | |
| 34 | printscip-perl cpan Date-Manip 6.99 main/print(). $date->printfscip-perl cpan Date-Manip 6.99 main/printf().($format),"\n"; |
| 35 |