Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Timestamp

568 views
Skip to first unread message

shiva...@gmail.com

unread,
Jan 11, 2013, 12:52:13 AM1/11/13
to
Hi

I tried getting timestamp using COMPUTETIMESTAMP procedure and getting 64 bit value.

I want 48 bit timestamp value.

Regards
Shivanshu

wbreidbach

unread,
Jan 11, 2013, 5:34:31 AM1/11/13
to
Use the CONTIME procedure instead of CUMPUTETIMESTAMP.

Keith Dick

unread,
Jan 11, 2013, 6:45:44 AM1/11/13
to
I think CONTIME is not what he needs. It takes a 48-bit timestamp and breaks it out into year, month, day, etc. He is trying to create a 48-bit timestamp given year, month, day, etc.

As far as I remember, there is no system-provided procedure to do that. However, it isn't very hard to do.

1. Compute the 64-bit timestamp for the date and time in question.
2. Compute the 64-bit timestamp for December 31, 1974 00:00.
3. Subtract 2 from 1.
4. Divide by 10,000 -- this adjusts microseconds to centiseconds.
5. Take the low-order 48 bits of the result in 4.

I think 00:00 on 12/31/1974 is correct. To check, take the 48-bit timestamp computed according to this procedure, use CONTIME to convert it to year, month, day, hour, minute, second and check that it gives the date-time you started with in step 1. If it does not, you probably will be off by something obvious, like a whole day, or a whole number of hours. But I think no adjustment will be needed.

Remember that the 48-bit timestamp is always local civil time, while the 64-bit timestamp can be GMT, local standard time, or local civil time (taking daylight savings into account). Since you do not tell COMPUTETIMESTAMP whether you want it to provide GMT, LST, or LCT, what it computes is the same as what you give it. If you give it a local standard time value, it will compute a LST 64-bit timestamp. So keep that in mind. Since with this procedure, you are computing both 64-bit timestamps, I think that issue won't affect the result.

wbreidbach

unread,
Jan 11, 2013, 8:45:30 AM1/11/13
to kd...@acm.org
Sorry, CONTIME works the other way round. And I agree, Keith, there is no procedure for that. The last time I used that 48-bit timestamp was many years ago and at the moment I have no idea what it could be used for. I am doing a lot with timestamps but I am only using the 64-bit timestamp. The only thing I remember using the 48 bits were the superseded calls like FILEINFO.

Doug Miller

unread,
Jan 11, 2013, 11:35:17 AM1/11/13
to
shiva...@gmail.com wrote in
news:4038c4e2-be14-4269...@googlegroups.com:

> I tried getting timestamp using COMPUTETIMESTAMP procedure and
> getting 64 bit value.
>
> I want 48 bit timestamp value.

RTFM. Guardian Programmer's Guide, Chapter 18, "Managing Time"

You don't say why you want to generate a 48-bit timestamp, so I'm
just speculating here: the most likely reason for wanting to do so
is that you want to compare an existing 48-bit timestamp to some
constant (e.g. is the 48-bit timestamp that you already have
before, or after, 1 June 2012 at 08:30:00 am, or some such).

BY FAR the easiest way of doing that is generate a 64-bit
timestamp using COMPUTETIMESTAMP as you are now doing, convert the
existing 48-bit timestamp to a 64-bit timestamp using CONTIME and
COMPUTETIMESTAMP, and compare the 64-bit values.

Bill Honaker

unread,
Jan 11, 2013, 12:27:57 PM1/11/13
to
You could simply use the TIMESTAMP() procedure

For C/C++:
#include <cextdecs(TIMESTAMP)>

int lowmem interval_clock[3];
TIMESTAMP ( interval_clock );

For TAL:
INT interval^clock [0:2];
CALL TIMESTAMP ( interval^clock );

Doug Miller

unread,
Jan 11, 2013, 2:49:41 PM1/11/13
to
Bill Honaker <no_spam_bhonaker__@x_i_d.com> wrote in
news:vni0f89evste47gmj...@4ax.com:

> On Thu, 10 Jan 2013 21:52:13 -0800 (PST), shiva...@gmail.com wrote:
>
>>Hi
>>
>>I tried getting timestamp using COMPUTETIMESTAMP procedure and getting 64 bit value.
>>
>>I want 48 bit timestamp value.
>>
>>Regards
>>Shivanshu
>
> You could simply use the TIMESTAMP() procedure

TIMESTAMP is the 48-bit equivalent of JULIANTIMESTAMP, not of COMPUTETIMESTAMP.

TIMESTAMP and JULIANTIMESTAMP return the current system time in 48 and 64 bits,
respectively. COMPUTETIMESTAMP constructs a 64-bit timestamp from supplied
parameters year, month, day, hour, etc. There is no corresponding system procedure to
construct 48-bit timestamps.

It can be done manually, though, without much difficulty. Construct a 64-bit timestamp, then
convert to 48 bits using this formula:

48-bit time = (64-bit local civil time minus 211024440000000000) / 10000

That long constant is the 64-bit timestamp of Time Zero in the 48-bit timestamp world (00:00 on
31 Dec 1974) and is obtained by calling COMPUTETIMESTAMP with the input array [1974,
12, 31, 0, 0, 0, 0, 0]. Dividing by 10,000 converts from microsecond resolution in 64 bits to
centisecond resolution in 48 bits.

mara...@prodigy.net

unread,
Jan 15, 2013, 3:24:02 AM1/15/13
to
The big thing to remember is that 48-bit timestamps are generally in local time whereas 64-bit timestamps can be local or universal.

If you want to be pedantic, the right way to compute a 48-bit timestamp is to to call CONTIME with a zero timestamp and then COMPUTETIMESTAMP with the result (multiplying the T[6] by 10 and puting a 0 into T[7] before the call). Convert the result to UTC with a call to CONVERTTIMESTAMP. Now you have BASE_JULIANTIMESTAMP. So, to compute the 48-bit COMPUTED_TIMESTAMP = (COMPUTETIMESTAMP (.....) - BASE_JULIANTIMESTAMP) / 10000.
From COMPUTED_TIMESTAMP you now have to extract the low order 3 words to create the 48-bit timestamp.
It's much easier to use 64-bit timestamps for everything. If you end up with a 48-bit one, you should be able to call CONTIME then COMPUTETIMESTAMP then CONVERTTIMESTAMP as above to straight it out.
0 new messages