Thread: How to read year in tm structure

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    20

    How to read year in tm structure

    hello,

    I would like to know how to read the year format in tm structure. I obtain 106 as 2006 year. Could some one tell me what is the rule and method to extract year format in tm structure of ISO C.

    Thank you.

  2. #2
    Just kidding.... fnoyan's Avatar
    Join Date
    Jun 2003
    Location
    Still in the egg
    Posts
    275
    Well, tm_year indicates years from 1900

  3. #3
    Registered User
    Join Date
    Nov 2005
    Posts
    20
    1900+106 = 2006

    Ok I understand the rule.

    Thank you.

  4. #4
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    If you look at the man pages for any given C function, it'll usually tell you everything you ever need to know about the function: http://unixhelp.ed.ac.uk/CGI/man-cgi?localtime+3
    Broken-down time is stored in the structure tm which is defined in
    <time.h> as follows:

    struct tm {
    int tm_sec; /* seconds */
    int tm_min; /* minutes */
    int tm_hour; /* hours */
    int tm_mday; /* day of the month */
    int tm_mon; /* month */
    int tm_year; /* year */
    int tm_wday; /* day of the week */
    int tm_yday; /* day in the year */
    int tm_isdst; /* daylight saving time */
    };
    ...
    tm_year
    The number of years since 1900.
    If you understand what you're doing, you're not learning anything.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. why does this program say 1700 is a leap year?
    By newbcore in forum C Programming
    Replies: 7
    Last Post: 12-19-2008, 02:03 AM
  2. "sorting news" assignment
    By prljavibluzer in forum C Programming
    Replies: 7
    Last Post: 02-06-2008, 06:45 AM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. Help ...
    By Enoz28 in forum C Programming
    Replies: 4
    Last Post: 07-05-2004, 09:07 PM
  5. Placing the Current Time in a tm structure
    By WebmasterMattD in forum Linux Programming
    Replies: 4
    Last Post: 04-06-2002, 08:27 AM