Connecting Tech Pros Worldwide Help | Site Map

timestamp question

 
LinkBack Thread Tools Search this Thread
  #1  
Old June 27th, 2008, 04:43 PM
wongjoekmeu@yahoo.com
Guest
 
Posts: n/a
Default timestamp question

Hello all,

I have a C++ program ( I am not sure if this is the right place to
post this question ), One of the function returns two unsigned
integers which are referred to be TimestampLo and TimestampHi. Can
anyone please help me out how I am supposed to convert these two
integer to an understandable timestamp. It says also for the
TimestampLo variable that this is the lower 32-bits and for the
TimestampHi variable is the higher 32-bits. What does that mean ? And
how do I construct the timestamp ? Thanks. If this is not the right
place to post this question can anyone please give me some suggestion
where I could post this ?

rr

  #2  
Old June 27th, 2008, 04:43 PM
=?UTF-8?B?RXJpayBXaWtzdHLDtm0=?=
Guest
 
Posts: n/a
Default Re: timestamp question

On 2008-05-19 20:54, wongjoekmeu@yahoo.com wrote:
Quote:
Hello all,
>
I have a C++ program ( I am not sure if this is the right place to
post this question ), One of the function returns two unsigned
integers which are referred to be TimestampLo and TimestampHi. Can
anyone please help me out how I am supposed to convert these two
integer to an understandable timestamp. It says also for the
TimestampLo variable that this is the lower 32-bits and for the
TimestampHi variable is the higher 32-bits. What does that mean ?
It means that the two integers are the two halves of one big (64-bit)
integer. TimestampLo contains bits 0-31 or the timestamp and TimestampHi
contains bits 32-63
Quote:
And how do I construct the timestamp ?
Put them back into a 64-bit integer (probably a long or a long long on
your platform, if you can use the uint64_t type to be sure). You can use
shifting and binary or to create the original timestamp like this:

uint64_t ts = TimestampHi;
ts = ts << 32;
ts = ts | TimestampLo;

Make sure that the 64-bit variable is unsigned.

--
Erik Wikström
  #3  
Old June 27th, 2008, 04:43 PM
Victor Bazarov
Guest
 
Posts: n/a
Default Re: timestamp question

wongjoekmeu@yahoo.com wrote:
Quote:
I have a C++ program ( I am not sure if this is the right place to
post this question ), One of the function returns two unsigned
integers which are referred to be TimestampLo and TimestampHi. Can
anyone please help me out how I am supposed to convert these two
integer to an understandable timestamp. It says also for the
TimestampLo variable that this is the lower 32-bits and for the
TimestampHi variable is the higher 32-bits. What does that mean ? And
how do I construct the timestamp ? Thanks. If this is not the right
place to post this question can anyone please give me some suggestion
where I could post this ?
It would be better if you asked in the newsgroup that deals with the
part of the system to which the timestamp applies. Is that a file?
Then it's likely that your question is OS-specific. Is that the
compilation unit? Then the compiler newsgroup is the right place. Is
that an Internet connection? Then you probably need to talk to the
makers of the 3rd party library you're using for your Internet access
(it can of course be the compiler vendor or the OS vendor).

C++ has several time values (basically coming from the C Standard
Library) and I don't know of any that would have a two-part design.
There is 'time_t' type, there is 'tm' type. That's about it. And the
functions that return those are quite well known and described in every
FM you can R.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
  #4  
Old June 27th, 2008, 04:43 PM
James Kanze
Guest
 
Posts: n/a
Default Re: timestamp question

On May 19, 9:21 pm, Erik Wikström <Erik-wikst...@telia.comwrote:
Quote:
On 2008-05-19 20:54, wongjoek...@yahoo.com wrote:
Quote:
I have a C++ program ( I am not sure if this is the right
place to post this question ), One of the function returns
two unsigned integers which are referred to be TimestampLo
and TimestampHi. Can anyone please help me out how I am
supposed to convert these two integer to an understandable
timestamp. It says also for the TimestampLo variable that
this is the lower 32-bits and for the TimestampHi variable
is the higher 32-bits. What does that mean ?
Quote:
It means that the two integers are the two halves of one big
(64-bit) integer. TimestampLo contains bits 0-31 or the
timestamp and TimestampHi contains bits 32-63
Quote:
Quote:
And how do I construct the timestamp ?
Quote:
Put them back into a 64-bit integer (probably a long or a long
long on your platform, if you can use the uint64_t type to be
sure). You can use shifting and binary or to create the
original timestamp like this:
Quote:
uint64_t ts = TimestampHi;
ts = ts << 32;
ts = ts | TimestampLo;
Quote:
Make sure that the 64-bit variable is unsigned.
Which still only gives you an integral value. What that
integral value means depends on the system, and he really needs
to look at the system documentation for that. (In this case,
the system also contains various functions for manipulating or
converting the original format. The only reason I can think of
for converting to uint64_t is to convert it to a standard
time_t, in which case, you'll have to follow up with a few
additional steps.)

--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,840 network members.