struct tm timeb

Discussion in 'C++' started by Jeff Kish, Nov 27, 2006.

  1. Jeff Kish

    Jeff Kish Guest

    I'm using an old compiler.
    Can someone tell me if there is a way to convert from a struct tm to a timeb?

    Not sure how to go about it. It is a really old app I'm working with.
    thanks
    Jeff
    Jeff Kish
    Jeff Kish, Nov 27, 2006
    #1
    1. Advertising

  2. Jeff Kish

    Mike Wahler Guest

    "Jeff Kish" <> wrote in message
    news:...
    > I'm using an old compiler.
    > Can someone tell me if there is a way to convert from a struct tm to a
    > timeb?
    >
    > Not sure how to go about it. It is a really old app I'm working with.
    > thanks


    You'll need to check your compiler's documentation.
    Standard C++ does not have a type 'timeb'.

    -Mike
    Mike Wahler, Nov 27, 2006
    #2
    1. Advertising

  3. Jeff Kish

    Jeff Kish Guest

    On Mon, 27 Nov 2006 15:47:01 GMT, "Mike Wahler" <> wrote:

    >
    >"Jeff Kish" <> wrote in message
    >news:...
    >> I'm using an old compiler.
    >> Can someone tell me if there is a way to convert from a struct tm to a
    >> timeb?
    >>
    >> Not sure how to go about it. It is a really old app I'm working with.
    >> thanks

    >
    >You'll need to check your compiler's documentation.
    >Standard C++ does not have a type 'timeb'.
    >
    >-Mike
    >

    sigh. thanks. this is really old...
    I think standard C does. Is this an area where C++ won't work with some C
    calls?

    Is there a recommended way to get from these sort of C time structures to C++?


    Jeff Kish
    Jeff Kish, Nov 27, 2006
    #3
  4. Jeff Kish wrote:
    > On Mon, 27 Nov 2006 15:47:01 GMT, "Mike Wahler"
    > <> wrote:
    >
    >>
    >> "Jeff Kish" <> wrote in message
    >> news:...
    >>> I'm using an old compiler.
    >>> Can someone tell me if there is a way to convert from a struct tm
    >>> to a timeb?
    >>>
    >>> Not sure how to go about it. It is a really old app I'm working
    >>> with. thanks

    >>
    >> You'll need to check your compiler's documentation.
    >> Standard C++ does not have a type 'timeb'.
    >>
    >> -Mike
    >>

    > sigh. thanks. this is really old...
    > I think standard C does. Is this an area where C++ won't work with
    > some C calls?


    Standard C does *not* have 'timeb'.

    > Is there a recommended way to get from these sort of C time
    > structures to C++?


    Post your code, post your requirements (or what the code used to do)
    and we can help you figure it out.

    Usually to get a C type into C++ you just drop the decoration (like
    in your case 'struct tm' becomes 'tm').

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
    Victor Bazarov, Nov 27, 2006
    #4
  5. Jeff Kish

    Larry Smith Guest

    Jeff Kish wrote:
    > I'm using an old compiler.
    > Can someone tell me if there is a way to convert from a struct tm to a timeb?
    >
    > Not sure how to go about it. It is a really old app I'm working with.
    > thanks
    > Jeff
    > Jeff Kish


    'timeb' was used by the old BSD ftime() function.
    The same basic info can be obtained by creating
    a 'tm' struct using ISO 9899 gmtime() or localtime().
    For example:

    #include <time.h>

    struct tm * pTm;
    struct tm tmNow;

    pTm = localtime( time(0) );

    /* if got the time, make a copy before another thread
    * changes the global used by localtime().
    * on unix, use the thread-safe localtime_r() instead.
    */
    if (pTm)
    tmNow = *pTm;
    else
    /* localtime() error */
    Larry Smith, Nov 27, 2006
    #5
    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. RA Scheltema
    Replies:
    3
    Views:
    380
    RA Scheltema
    Jan 6, 2004
  2. Gunnar G

    struct in struct

    Gunnar G, May 31, 2004, in forum: C++
    Replies:
    14
    Views:
    786
  3. DanielEKFA
    Replies:
    8
    Views:
    589
    DanielEKFA
    May 16, 2005
  4. James Harris
    Replies:
    4
    Views:
    1,359
    James Harris
    Oct 9, 2003
  5. Chris Fogelklou
    Replies:
    36
    Views:
    1,354
    Chris Fogelklou
    Apr 20, 2004
Loading...

Share This Page