Interpretation of tm_isdst field in struct tm

Viewed 6751

Time structure (struct tm) contains a calendar date and time broken down into its components. The structure contains nine members of type int (in any order), which are:

Member  Type    Meaning Range
tm_sec  int seconds after the minute    0-61*
tm_min  int minutes after the hour  0-59
tm_hour int hours since midnight    0-23
tm_mday int day of the month    1-31
tm_mon  int months since January    0-11
tm_year int years since 1900    
tm_wday int days since Sunday   0-6
tm_yday int days since January 1    0-365
tm_isdst    int Daylight Saving Time flag

The Daylight Saving Time flag (tm_isdst) is greater than zero if Daylight Saving Time is in effect, zero if Daylight Saving Time is not in effect, and less than zero if the information is not available.

My Specific Questions related to tm_isdst are as follows:

  1. For date(YYYY-MM-DD) 2016-03-16 (when DST is in effect), should tm_isdst be 1? or 0?

  2. For date(YYYY-MM-DD) 2016-01-16 (when DST was not in effect), should tm_isdst be 1? or 0?

  3. Daylight Saving Time (United States) 2016 began at 2:00 AM on Sunday, March 13. So at say 1:45AM on March 13, what would be value of tm_isdst? Who sets this value of flag and how?

  4. Is there any way to check when DST was in effect from some system call?

2 Answers
Related