Why does tm_mday start from 1 while all other elements of struct tm start from 0?
04:45 13 Jul 2015

While answering another question, I told the OP he needs to initialize his struct tm variable correctly but needs to be careful because he couldn't simply use

struct tm mytime;
memset(&mytime, 0, sizeof(mytime));

because not all fields of struct tm are valid from 0. A closer look on struct tm showed me that it is exactly one field of struct tm that doesn't have 0 as valid value, namely tm_mday:

int    tm_sec   seconds [0,61]
int    tm_min   minutes [0,59]
int    tm_hour  hour [0,23]
int    tm_mday  day of month [1,31]
int    tm_mon   month of year [0,11]
int    tm_year  years since 1900
int    tm_wday  day of week [0,6] (Sunday = 0)
int    tm_yday  day of year [0,365]
int    tm_isdst daylight savings flag

Why? What were the thoughts behind the decision that for this very element, 0 shall be no valid value???

c time struct mktime