Qmail
[Top] [All Lists]

Re: tai64n date format

To: qmail@list.cr.yp.to
Subject: Re: tai64n date format
From: Jeremy Kister <qmail-06@jeremykister.com>
Date: Sun, 01 Apr 2007 14:40:45 -0400
Delivered-to: sp-com-lists@consult.net
Delivered-to: gmail-qmail@securepoint.com
Delivered-to: sp.com.list@gmail.com
Delivered-to: mailing list qmail@list.cr.yp.to
In-reply-to: <a3bd4fe00704011052n1132c340k1320805947292f73@mail.gmail.com>
Mailing-list: contact qmail-help@list.cr.yp.to; run by ezmlm
References: <a3bd4fe00704011052n1132c340k1320805947292f73@mail.gmail.com>
User-agent: Thunderbird 1.5.0.10 (Windows/20070221)
On 4/1/2007 1:52 PM, Vahid Moghaddasi wrote:
> I am trying to separate the log entries, based on the date and time
> but I have difficulties identifying the time stamp without piping the
> logs to tai64nlocal utility.

TAI64N is documented at http://cr.yp.to/daemontools/tai64n.html

It's going to be hard to convert just by eye :).  Are you trying to do
this in some scripting language?

> Is there a way to find out a given date and time e.g. 2007-04-01
> 13:40:46.790878500 in TAI format? This date in TAI is:
> "@40000000460feea82f23d924" in qmail/current file.


here's some perl that may help:

#!/usr/local/bin/perl

use strict;

my $ts = '@40000000460feea82f23d924';

$ts =~ /([a-f0-9]{8})([a-f0-9]{8})$/;
my ($ws,$fs) = (hex($1),hex($2));

my($sec,$min,$hour,$mday,$mon,$year) = (localtime($ws))[0,1,2,3,4,5];

$year += 1900;
$mon++;

my $date = sprintf("%04d-%02d-%02d %02d:%02d:%02d.%09d", $year, $mon,
$mday, $hour, $min, $sec, $fs);

print "date: $date\n";

__END__


-- 

Jeremy Kister
http://jeremy.kister.net./


<Prev in Thread] Current Thread [Next in Thread>