[rrd-users] date/timestamp conversion (was Some values become NaN...)

steve rader rader at teak.wiscnet.net
Thu Jul 27 11:21:32 MEST 2000


 
 > One small remark:  Please use the date format that is used in the
 > rrdtool dump.  This is why:
 >    [alex at home /tmp/test]$ date -d '26.07.2000 23:45:00' +%s
 >    date: invalid date `26.07.2000 23:45:00'
 > 
 >    [alex at home /tmp/test]$ date -d '2000-07-26 23:45:00' +%s
 >    964647900

I keep forgeting to post these little scripts... so here they
are now (following my signature)... I suspect they'll be handy
to a lot of folks...

 ginseng(rader): date
 Wed Jul 26 20:07:50 CDT 2000

 ginseng(rader): date2stamp 20:07:50 26 Jul 2000
 964660070

 ginseng(rader): stamp2date 964660070
 Wed Jul 26 20:07:50 2000

"date2stamp" requires "date" from GNU sh-utils, btw.  But don't
let that stop ya: sh-utils is very easy to build and install.

steve 
- - - 
systems & network guy
high energy physics
university of wisconsin


"stamp2date":

-- cut here --
#!/usr/bin/perl
if ( $#ARGV == 0 ) {
  print scalar localtime($ARGV[0]), "\n";
} else {
  print "usage: stamp2date seconds_since_unix_epoch\n";
  exit 1;
}
-- cut here --


"date2stamp":

-- cut here --
#!/usr/bin/perl
$date = "/bin/date";
if ( `$date --version` !~ /sh-utils/ ) {
  print "failed: $date must be from the GNU sh-utils package\n";
  exit 1;
}
if ( $#ARGV > -1 ) {
  $argv = join(' ', at ARGV);
  print `$date -d "$argv" +%s`;
} else {
  print "usage: date2stamp at_style_time_specification\n";
  exit 1;
}
-- cut here--




--
Unsubscribe mailto:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-users-request at list.ee.ethz.ch?subject=help
Archive     http://www.ee.ethz.ch/~slist/rrd-users
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi



More information about the rrd-users mailing list