Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: time functions weirdness |
| Date | 2016-09-18 20:40 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <87eg4hj8tr.fsf@bsb.me.uk> (permalink) |
| References | <e45d70Fk5lU1@mid.individual.net> <47758107-38f4-9571-76db-1e5991639649@verizon.net> <e45n6uF2va9U1@mid.individual.net> <lnpoo2xdeu.fsf@kst-u.example.com> <e46qaqFbdu0U1@mid.individual.net> |
Robert Latest <boblatest@yahoo.com> writes:
> Keith Thompson wrote:
>> Robert Latest <boblatest@yahoo.com> writes:
>> [...]
>>> BTW, what where the early C'ers smoking when they came up with the idea of
>>> making the tm_mon field zero-based. Of course real coders always start
>>> counting at zero, but then why does tm_mday start at 1?
>> [...]
>>
>> For human-readable display, months are very commonly represented
>> as strings ("Jan" or "January", etc., or the equivalent in the
>> local language). The obvious way to do that is to use the month
>> number as an index into an array:
>>
>> const char *const month_name = { "Jan", "Feb", ... };
>>
>> It was probably considered cleaner not to give the array an ignored
>> zeroth element.
>
> That's an excellent thought! I had really been puzzled about this for a long
> time because this is an apparent inconsistency that must have been designed
> into the struct tm type on the same day by the same person (unlike other
> inconsistencies that come from different philosophies held by different
> people at different times). It sounds really plausible, so I'll stick
> with it.
Note that tm_wday (the week day that would often also have to be mapped
to strings) is also zero based.
--
Ben.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
time functions weirdness Robert Latest <boblatest@yahoo.com> - 2016-09-17 17:35 +0000
Re: time functions weirdness Robert Latest <boblatest@yahoo.com> - 2016-09-17 17:38 +0000
Re: time functions weirdness "James R. Kuyper" <jameskuyper@verizon.net> - 2016-09-17 14:26 -0400
Re: time functions weirdness Robert Latest <boblatest@yahoo.com> - 2016-09-17 20:26 +0000
Re: time functions weirdness "James R. Kuyper" <jameskuyper@verizon.net> - 2016-09-17 17:21 -0400
Re: time functions weirdness Keith Thompson <kst-u@mib.org> - 2016-09-17 16:54 -0700
Re: time functions weirdness "James R. Kuyper" <jameskuyper@verizon.net> - 2016-09-17 18:00 -0400
Re: time functions weirdness Ian Collins <ian-news@hotmail.com> - 2016-09-18 10:45 +1200
Re: time functions weirdness Keith Thompson <kst-u@mib.org> - 2016-09-17 17:24 -0700
Re: time functions weirdness Robert Latest <boblatest@yahoo.com> - 2016-09-18 06:25 +0000
Re: time functions weirdness Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-18 20:40 +0100
Re: time functions weirdness supercat@casperkitty.com - 2016-09-18 16:00 -0700
Re: time functions weirdness Keith Thompson <kst-u@mib.org> - 2016-09-17 17:04 -0700
csiph-web