Discussion:
[omniORB] TimeBase to string
João Lopes
2007-05-16 22:37:30 UTC
Permalink
Hi, I have this object:

CORBA.TypeCode("IDL:omg.org/TimeBase/UtcT:1.0"),
TimeBase.UtcT(time=133980174680000000L, inacclo=0L, inacchi=0, tdf=0))

How can I conver this to a date/time string (YYYY/MM/DD HH:MM:SS) ??
or to something that can be read by a human.

thanks
Jo?o Lopes
Duncan Grisby
2007-06-07 00:03:03 UTC
Permalink
Post by João Lopes
CORBA.TypeCode("IDL:omg.org/TimeBase/UtcT:1.0"),
TimeBase.UtcT(time=133980174680000000L, inacclo=0L, inacchi=0, tdf=0))
How can I conver this to a date/time string (YYYY/MM/DD HH:MM:SS) ??
or to something that can be read by a human.
CORBA's time format comes from DCE. The number in it is the number of
100 nanosecond intervals since 15th October 1582. There's nothing in
omniORB that knows anything about that, but I happen to have a little
function that handles it:


# Number of seconds between Unix epoch and DCE epoch
UNIX_TO_UTC_OFFSET_SECS = 12219292800L

def convertToUnix(utc):
"""convertToUnix(dtime) -> time in Unix format"""

sinceunix = utc - (UNIX_TO_UTC_OFFSET_SECS * 10000000)
secs = sinceunix / 10000000.0
return secs


The convertToUnix function converts the DCE time to Unix time as a
floating point value. You can then give it to standard things like
time.ctime() to convert it to a string.

Cheers,

Duncan.
--
-- Duncan Grisby --
-- ***@grisby.org --
-- http://www.grisby.org --
Loading...