4 ms·
Am I the only one that finds it weird that the tm_mday field in the tm struct is the only one that starts from 1? I understand it doesn't make much sense to ha
by carlob 12y ago
Am I the only one that finds it weird that the tm_mday field in the tm struct is the only one that starts from 1?
I understand it doesn't make much sense to have tm_mday start from 0, but then again even 3 as April seems weird, maybe they should all start at 1.
http://pubs.opengroup.org/onlinepubs/007908775/xsh/time.h.html http://pubs.opengroup.org/onlinepubs/007908775/xsh/time.h.ht...
- tzs 12y agotm_mon and tm_wday are 0-based because the expectation was you'll probably be using than as an index in a lookup table to get a month name (e.g., "Jan", "Feb", ...) or day name (e.g., "Sun", "Mon", ...). For day of month, we don't have special names for them. We just use the day number. So tm_mday directly contains the day number.
- carlob 12y agoThat's right, but what about tm_yday then?