3 #=======================================================================
5 # File ID: 37c2594c-f743-11dd-b452-000475e441b9
7 # Continuously print date and timestamp, mostly used to check the sync
10 # Character set: UTF-8
11 # ©opyleft 2006– Øyvind A. Holm <sunny@sunbase.org>
12 # License: GNU General Public License version 2 or later, see end of
13 # file for legal stuff.
14 #=======================================================================
19 use Time
::HiRes
qw{ gettimeofday usleep
};
34 $progname =~ s/^.*\/(.*?)$/$1/;
35 our $VERSION = '0.2.1';
37 Getopt
::Long
::Configure
('bundling');
40 'epoch|e' => \
$Opt{'epoch'},
41 'help|h' => \
$Opt{'help'},
42 'quiet|q+' => \
$Opt{'quiet'},
43 'verbose|v+' => \
$Opt{'verbose'},
44 'version' => \
$Opt{'version'},
46 ) || die("$progname: Option error. Use -h for help.\n");
48 $Opt{'verbose'} -= $Opt{'quiet'};
49 $Opt{'help'} && usage
(0);
50 if ($Opt{'version'}) {
61 my ($Old, $Str) = ("", "");
62 my $time_str = $Opt{'epoch'} ?
"%s" : "%04u-%02u-%02u %02u:%02u:%02uZ";
67 my ($Epoch, $Fract) = gettimeofday
();
68 my ($Sec, $Min, $Hour, $Day, $Mon, $Year, $Wday, $Yday, $is_dst) =
70 $Str = sprintf($time_str,
71 $Opt{'epoch'} ?
$Epoch
72 : ($Year+1900, $Mon+1, $Day, $Hour, $Min, $Sec));
73 } while ($Str eq $Old);
84 # Print program version {{{
85 print("$progname $VERSION\n");
91 # Send the help message to stdout {{{
94 if ($Opt{'verbose'}) {
100 Continuously print date and timestamp, mostly used to check the sync
103 Usage: $progname [options]
108 Display Unix time (seconds since 1970-01-01 00:00:00 UTC) instead of
109 the default ISO 8601 format.
113 Be more quiet. Can be repeated to increase silence.
115 Increase level of verbosity. Can be repeated.
117 Print version information.
125 # Print a status message to stderr based on verbosity level {{{
126 my ($verbose_level, $Txt) = @_;
128 if ($Opt{'verbose'} >= $verbose_level) {
129 print(STDERR
"$progname: $Txt\n");
137 # This program is free software; you can redistribute it and/or modify
138 # it under the terms of the GNU General Public License as published by
139 # the Free Software Foundation; either version 2 of the License, or (at
140 # your option) any later version.
142 # This program is distributed in the hope that it will be useful, but
143 # WITHOUT ANY WARRANTY; without even the implied warranty of
144 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
145 # See the GNU General Public License for more details.
147 # You should have received a copy of the GNU General Public License
148 # along with this program.
149 # If not, see L<http://www.gnu.org/licenses/>.
151 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :