2

I am in the process of optimizing some UniVerse data access code we have which uses UniObjects. After some experimentation, it seems that using a UniSession.OConv call to parse certain things such as decimal numbers (most we have a MR4 or MR2 or MR2$) and dates (almost all are D2/) is extremely slow (I think it might make a call back to the server to parse it).

I have already built a parser for the MR*[$] codes, but I was wondering about the dates as they are stored so I can build one for D2/. Usually they seem to be stored as a 5 digit number. I thought it could be number of days since the Unix Epoch since our UniVerse server runs on HP-UX, but after finding '15766' as a last modified date and multiplying it by 86400 (seconds per day), I got March 02, 2013 which doesn't make sense as a last modified date since as far as I know that is still in the future.

Does anyone know what the time base of these date numbers are?

Los Frijoles
  • 4,771
  • 5
  • 30
  • 49

3 Answers3

5

It is stored as a number of days. Just do a conversion on 0 and you will get the start date.

Edit:

As noted by Los, the Epoch used in UniVerse (and UniData) is 31st Dec 1967.

Dan McGrath
  • 41,220
  • 11
  • 99
  • 130
  • I got that the base is 12/31/1967. Doing OConv("15766", "D2/") and (new DateTime(1967, 12, 31)).AddDays(15766) gave me the same thing. Thanks a ton! – Los Frijoles Nov 01 '12 at 00:55
  • Just to give some stats: Converting 1000 random integers into dates between 0 and 16000 yielded 1.2561ms average per conversion for OConv and 0.002ms average per conversion for the datetime addition method. – Los Frijoles Nov 01 '12 at 01:04
2

In Universe and any other Pick database, Dates and Times are stored as separate values.

The internal date is the number of days before of after 31/12/1967, which is day zero.

The internal time is the number of seconds after midnight. It can be stored as a decimal but is not normally.

0

In TCL there is a CDT command (stands for Convert Date) that converts dates from human readable to numeric and and vice versa:

CDT 9/28/2017 
 * Result: 18169  

CDT 18169     
 * Result: 09/28/2017     
Bill Zelenko
  • 2,606
  • 1
  • 17
  • 26