[omniORB] TimeBase to string

Duncan Grisby duncan at grisby.org
Wed Jun 6 20:03:13 BST 2007


On Wednesday 16 May, "=?UTF-8?Q?Jo=C3=A3o_Lopes?=" wrote:

> 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         --
  -- duncan at grisby.org     --
   -- http://www.grisby.org --



More information about the omniORB-list mailing list