#!/usr/bin/env perl require 5.002; use strict; use POSIX qw(strftime); # DESCRIPTION # fraclocal converts fractional timestamps in seconds since epoch # to human-readable form. # # INTERFACE # fraclocal reads lines from STDIN. If a line does not start with # a fractional number, fraclocal writes it to STDOUT without change. # If the line starts with a fractional number, fraclocal writes the line # to STDOUT with the timestamp converted to local time in ISO format: # YYYY-MM-DD HH:MM:SS # made by Paul Kremer (pkremer [at] spurious [dot] biz) # version: 2003/04/07 # License: BSD artistic while(<>) { my $s = $_; # ignore non frac lines if ( ! /^\d+\.\d+/ ) { print $s; next;} my @fracline = split / /, $s,2; $fracline[0] = strftime "%Y-%m-%d %H:%M:%S", localtime($fracline[0]); print $fracline[0] .' '. $fracline[1]; unless ($_) { last; }; }