Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: time functions weirdness |
| Date | 2016-09-17 17:24 -0700 |
| Organization | None to speak of |
| Message-ID | <lnpoo2xdeu.fsf@kst-u.example.com> (permalink) |
| References | <e45d70Fk5lU1@mid.individual.net> <47758107-38f4-9571-76db-1e5991639649@verizon.net> <e45n6uF2va9U1@mid.individual.net> |
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.
Days of the month do not have names (at least in the cultures
considered at the time), so there's no need to use them as indices.
If they did, tm_mday would likely have been given a range of 0..30
rather than 1..31.
I do think it would have been cleaner to give tm_mon a range of
1..12 rather than 0..11, but the decision that was made was fairly
reasonable, and we're stuck with it. Offsetting tm_year by 1900 was
less defensible, but when the interface was developed, probably in
the 1970s, it was common to use just the last 2 digits of the year.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
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