Try this gawk script to see if works for you. I modified mktime.awk to
process my trace files by putting the date text along with the tim
value. I ran your sample and got the result show below. I'm be
interested in knowing if it works for anybody else.=20
Tony Aponte
Home Shopping Network, Inc.
- sample run --------------------
$ echo "PARSE
#30:c=3D2,e=3D15,p=3D0,cr=3D0,cu=3D0,mis=3D1,r=3D0,dep=3D0,og=3D4,tim=3D9=
33354557" | gawk -f
mktime.awk
PARSE =
#30:c=3D2,e=3D15,p=3D0,cr=3D0,cu=3D0,mis=3D1,r=3D0,dep=3D0,og=3D4,tim=3D9=
33354557
04/27/2004 10:16:08
$
- the gawk script ---------------
# mktime.awk --- convert a canonical date representation
# into a timestamp
# Arnold Robbins, arnold_at_gnu.org, Public Domain
# May 1993
BEGIN \
{
# Initialize table of month lengths
_tm_months[0,1] =3D _tm_months[1,1] =3D 31
_tm_months[0,2] =3D 28; _tm_months[1,2] =3D 29
_tm_months[0,3] =3D _tm_months[1,3] =3D 31
_tm_months[0,4] =3D _tm_months[1,4] =3D 30
_tm_months[0,5] =3D _tm_months[1,5] =3D 31
_tm_months[0,6] =3D _tm_months[1,6] =3D 30
_tm_months[0,7] =3D _tm_months[1,7] =3D 31
_tm_months[0,8] =3D _tm_months[1,8] =3D 31
_tm_months[0,9] =3D _tm_months[1,9] =3D 30
_tm_months[0,10] =3D _tm_months[1,10] =3D 31
_tm_months[0,11] =3D _tm_months[1,11] =3D 30
_tm_months[0,12] =3D _tm_months[1,12] =3D 31
}
# decide if a year is a leap year
function _tm_isleap(year, ret)
{
ret =3D (year % 4 =3D=3D 0 && year % 100 !=3D 0) ||
(year % 400 =3D=3D 0)
=20
return ret
}
# convert a date into seconds
function _tm_addup(a, total, yearsecs, daysecs,
hoursecs, i, j)
{
hoursecs =3D 60 * 60
daysecs =3D 24 * hoursecs
yearsecs =3D 365 * daysecs
=20
total =3D (a[1] - 1970) * yearsecs
=20
# extra day for leap years
for (i =3D 1970; i < a[1]; i++)
if (_tm_isleap(i))
total +=3D daysecs
=20
j =3D _tm_isleap(a[1])
for (i =3D 1; i < a[2]; i++)
total +=3D _tm_months[j, i] * daysecs
=20
total +=3D (a[3] - 1) * daysecs
total +=3D a[4] * hoursecs
total +=3D a[5] * 60
total +=3D a[6]
=20
return total
}
# mktime --- convert a date into seconds,
# compensate for time zone
=20
function mktime(str, res1, res2, a, b, i, j, t, diff)
{
i =3D split(str, a, " ") # don't rely on FS
=20
if (i !=3D 6)
return -1
=20
# force numeric
for (j in a)
a[j] +=3D 0
=20
# validate
if (a[1] < 1970 ||
a[2] < 1 || a[2] > 12 ||
a[3] < 1 || a[3] > 31 ||
a[4] < 0 || a[4] > 23 ||
a[5] < 0 || a[5] > 59 ||
a[6] < 0 || a[6] > 60 )
return -1
=20
res1 =3D _tm_addup(a)
t =3D strftime("%Y %m %d %H %M %S", res1)
=20
if (_tm_debug)
printf("(%s) -> (%s)\n", str, t) > "/dev/stderr"
=20
split(t, b, " ")
res2 =3D _tm_addup(b)
=20
diff =3D res1 - res2
=20
if (_tm_debug)
printf("diff =3D %d seconds\n", diff) > "/dev/stderr"
=20
res1 +=3D diff
=20
return res1
}
BEGIN {
if (_tm_test) {
printf "Enter date as yyyy mm dd hh mm ss: "
getline _tm_test_date
t =3D mktime(_tm_test_date)
r =3D strftime("%Y %m %d %H %M %S", t)
printf "Got back (%s)\n", r
}
}
/tim=3D/ {
timv=3Dsubstr($0,index($0,"tim=3D")+4)
timv=3Dsubstr(timv,1,match(timv,/ |$/)-1)
stim=3D(6*17895697051) #Epoch in HSecs less the v$timer
timv=3Dstim + timv #Add v$timer=20
timv=3Dint(timv/100) #Convert from HSecs to Seconds
##sub(/tim=3D[0-9]*/,"& " strftime("%Y %m %d %H %M %S", timv) " ("timv
")")
sub(/tim=3D[0-9]*/,"& " strftime("%m/%d/%Y %H:%M:%S", timv))
}
{print $0}
-----Original Message-----
From: DEEDSD_at_Nationwide.com [mailto:DEEDSD_at_Nationwide.com]
Sent: Tuesday, April 27, 2004 11:59 AM
To: oracle-l_at_freelists.org
Subject: Re: time in trace file
There's a Perl script in Cary's book that converts from tim to real
date/time and back. It's example 6-10 on page 134.
=20
"Sultan Syed"
<ssyed_at_fine.ae> T
To: "oracle
freelists.org" <oracle-l_at_freelists.org> =20
Sent by: cc:
oracle-l-bounce_at_freelis
ts.org bcc:
Subject:
time in trace file =20
=20
=20
04/27/2004 02:48 AM
Please respond to
oracle-l
=20
=20
Hi guys,
How can I interpret with this time format,I know this is the time
of parse call is over,but how can I convert this into
date format.Is it possible?
PARSE =
#30:c=3D2,e=3D15,p=3D0,cr=3D0,cu=3D0,mis=3D1,r=3D0,dep=3D0,og=3D4,tim=3D9=
33354557
Thanks in advance
Syed
Please see the official ORACLE-L FAQ:
http://www.orafaq.com
To unsubscribe send email to: oracle-l-request_at_freelists.org
put 'unsubscribe' in the subject line.
--
Archives are at http://www.freelists.org/archives/oracle-l/
FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html
-----------------------------------------------------------------
----------------------------------------------------------------
Please see the official ORACLE-L FAQ: http://www.orafaq.com
----------------------------------------------------------------
To unsubscribe send email to: oracle-l-request_at_freelists.org
put 'unsubscribe' in the subject line.
--
Archives are at http://www.freelists.org/archives/oracle-l/
FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html
-----------------------------------------------------------------
----------------------------------------------------------------
Please see the official ORACLE-L FAQ: http://www.orafaq.com
----------------------------------------------------------------
To unsubscribe send email to: oracle-l-request_at_freelists.org
put 'unsubscribe' in the subject line.
--
Archives are at http://www.freelists.org/archives/oracle-l/
FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html
-----------------------------------------------------------------
Received on Wed Apr 28 2004 - 16:31:46 CDT