Debian Codegraph @

internal/printf_format.pl

raw symbols SCIP
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::Date;
14 my $date = new Date::Manip::Date;
15
16 my $posix = 0;
17 if (lc($ARGV[0]) eq 'posix') {
18 $posix = 1;
19 shift(@ARGV);
20 }
21 my $format = $ARGV[0];
22 my $time = $ARGV[1];
23
24 if ($posix) {
25 $date->config('use_posix_printf',1);
26 }
27
28 if ($time) {
29 $date->parse("epoch $time");
30 } else {
31 $date->parse('now');
32 }
33
34 print $date->printf($format),"\n";
35