Advertisement
iarmin

Relative time to Absolute time

Dec 28th, 2011
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.35 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. $uptime = `cat /proc/uptime | awk '{print $1}';`;
  4. $boot = time() - $uptime;
  5. chomp $boot;
  6. while (<STDIN>) {
  7.         if ($_ =~ /^\[([\s\d\.]+)\]/) {
  8.                 $time_offset = $1;
  9.         }
  10.         $real_time = sprintf scalar localtime($boot + $time_offset);
  11.         $_ =~ s/\[[\s\d\.]+\]/\[$real_time\]/;
  12.         print $_;
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement