C wiki - struct tm

Discussion in 'C Programming' started by Kenneth Brody, Aug 24, 2005.

  1. http://alien.dowling.edu/~rohit/wiki/index.php/C_Programming#Standard_Library

    Q: How are months of a year numbered in C?

    Answer makes reference to "the Standard specifies struct tm". Does the
    C standard actually define struct tm, or is it Posix that defines it?

    --
    +-------------------------+--------------------+-----------------------------+
    | Kenneth J. Brody | www.hvcomputer.com | |
    | kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer.h> |
    +-------------------------+--------------------+-----------------------------+
    Don't e-mail me at: <mailto:>
    Kenneth Brody, Aug 24, 2005
    #1
    1. Advertising

  2. Kenneth Brody

    Eric Sosman Guest

    Eric Sosman, Aug 24, 2005
    #2
    1. Advertising

  3. Kenneth Brody

    Ben Pfaff Guest

    Kenneth Brody <> writes:

    > Q: How are months of a year numbered in C?
    >
    > Answer makes reference to "the Standard specifies struct tm". Does the
    > C standard actually define struct tm, or is it Posix that defines it?


    It is in the C standard. See e.g. C99 7.23.1 paragraphs 3 and 4.
    --
    "I'm not here to convince idiots not to be stupid.
    They won't listen anyway."
    --Dann Corbit
    Ben Pfaff, Aug 24, 2005
    #3
  4. Kenneth Brody

    Simon Biber Guest

    Kenneth Brody wrote:
    > http://alien.dowling.edu/~rohit/wiki/index.php/C_Programming#Standard_Library
    >
    > Q: How are months of a year numbered in C?
    >
    > Answer makes reference to "the Standard specifies struct tm". Does the
    > C standard actually define struct tm, or is it Posix that defines it?


    The C standard defines struct tm as follows:

    7.23 Date and time <time.h>
    7.23.1 Components of Time
    ....
    4 The range and precision of times representable in clock_t and
    time_t are implementation-defined. The tm structure shall
    contain at least the following members, in any order. The
    semantics of the members and their normal ranges are expressed
    in the comments.

    int tm_sec; // seconds after the minute — [0, 60]
    int tm_min; // minutes after the hour — [0, 59]
    int tm_hour; // hours since midnight — [0, 23]
    int tm_mday; // day of the month — [1, 31]
    int tm_mon; // months since January — [0, 11]
    int tm_year; // years since 1900
    int tm_wday; // days since Sunday — [0, 6]
    int tm_yday; // days since January 1 — [0, 365]
    int tm_isdst; // Daylight Saving Time flag

    The value of tm_isdst is positive if Daylight Saving Time is
    in effect, zero if Daylight Saving Time is not in effect, and
    negative if the information is not available.

    --
    Simon.
    Simon Biber, Aug 24, 2005
    #4
  5. Hello,

    Simon Biber <> schrieb:

    > int tm_sec; // seconds after the minute — [0, 60]
    > int tm_min; // minutes after the hour — [0, 59]


    Is tm_sec really from 0 to 60 (including)? I do not see the sense of it
    in contrast to all the others (0.59 for minutes, 0..23 for hour, ...)

    What is the rationale behind this? Does it have anything to do with leap
    seconds?

    Curious,
    Spiro.

    --
    Spiro R. Trikaliotis http://cbm4win.sf.net/
    http://www.trikaliotis.net/ http://www.viceteam.org/
    Spiro Trikaliotis, Aug 25, 2005
    #5
  6. Spiro Trikaliotis wrote:
    > Is tm_sec really from 0 to 60 (including)? I do not see the sense of it
    > in contrast to all the others (0.59 for minutes, 0..23 for hour, ...)
    >
    > What is the rationale behind this? Does it have anything to do with leap
    > seconds?


    Yes.
    --
    Stephen Hildrey
    Mail: / Tel: +442071931337
    Jabber: / MSN:
    Stephen Hildrey, Aug 25, 2005
    #6
  7. In article <> Spiro Trikaliotis <> writes:
    > Simon Biber <> schrieb:
    >
    > > int tm_sec; // seconds after the minute — [0, 60]
    > > int tm_min; // minutes after the hour — [0, 59]

    >
    > Is tm_sec really from 0 to 60 (including)? I do not see the sense of it
    > in contrast to all the others (0.59 for minutes, 0..23 for hour, ...)
    >
    > What is the rationale behind this? Does it have anything to do with leap
    > seconds?


    It has everything to do with leap seconds.
    --
    dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
    home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/
    Dik T. Winter, Aug 25, 2005
    #7
  8. Kenneth Brody

    CBFalconer Guest

    Spiro Trikaliotis wrote:
    > Simon Biber <> schrieb:
    >
    >> int tm_sec; // seconds after the minute — [0, 60]
    >> int tm_min; // minutes after the hour — [0, 59]

    >
    > Is tm_sec really from 0 to 60 (including)? I do not see the sense
    > of it in contrast to all the others (0.59 for minutes, 0..23 for
    > hour, ...)
    >
    > What is the rationale behind this? Does it have anything to do
    > with leap seconds?


    Precisely. i.e. yes.

    --
    "If you want to post a followup via groups.google.com, don't use
    the broken "Reply" link at the bottom of the article. Click on
    "show options" at the top of the article, then click on the
    "Reply" at the bottom of the article headers." - Keith Thompson
    CBFalconer, Aug 25, 2005
    #8
    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. chris
    Replies:
    4
    Views:
    888
    chris
    May 17, 2004
  2. Eric @ Zomething

    Python Wiki & wiki Hosting?

    Eric @ Zomething, Jun 5, 2004, in forum: Python
    Replies:
    2
    Views:
    533
  3. Eric S. Johansson

    Re: Python Wiki & wiki Hosting?

    Eric S. Johansson, Jun 6, 2004, in forum: Python
    Replies:
    6
    Views:
    500
    Paul Boddie
    Jun 8, 2004
  4. Mahrt, Dallas

    RE: Python Wiki & wiki Hosting?

    Mahrt, Dallas, Jun 7, 2004, in forum: Python
    Replies:
    0
    Views:
    421
    Mahrt, Dallas
    Jun 7, 2004
  5. Replies:
    0
    Views:
    321
Loading...

Share This Page