timestamp question

Discussion in 'C++' started by wongjoekmeu@yahoo.com, May 19, 2008.

  1. Guest

    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
     
    , May 19, 2008
    #1
    1. Advertising

  2. On 2008-05-19 20:54, wrote:
    > 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

    > 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
     
    Erik Wikström, May 19, 2008
    #2
    1. Advertising

  3. James Kanze Guest

    On May 19, 9:21 pm, Erik Wikström <> wrote:
    > On 2008-05-19 20:54, wrote:
    > > 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


    > > 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.


    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:
    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
     
    James Kanze, May 20, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Manzoorul Hassan

    Convert to NTP Timestamp

    Manzoorul Hassan, Mar 11, 2005, in forum: Perl
    Replies:
    1
    Views:
    2,717
    Jim Gibson
    Mar 11, 2005
  2. Shawn

    displaying sybase timestamp

    Shawn, Jan 27, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    3,151
    Shawn
    Jan 27, 2004
  3. Greg Collins [MVP]

    File Timestamp and Saving Transformed XML to Server

    Greg Collins [MVP], Jul 8, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    464
    Greg Collins [MVP]
    Jul 12, 2004
  4. Sean Berry

    question about timestamp and MySQLdb

    Sean Berry, Oct 19, 2005, in forum: Python
    Replies:
    3
    Views:
    385
    Dennis Lee Bieber
    Oct 21, 2005
  5. J055
    Replies:
    1
    Views:
    756
    Walter Wang [MSFT]
    Aug 8, 2006
Loading...

Share This Page