Path: csiph.com!news.swapon.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: time functions weirdness Date: Sat, 17 Sep 2016 17:24:57 -0700 Organization: None to speak of Lines: 33 Message-ID: References: <47758107-38f4-9571-76db-1e5991639649@verizon.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="15983"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/gYvUdVn4oswxjINAVFUtG" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:PPTbGr3UG6CRFK7WnDBjmAjdt34= sha1:rnyAo8JVbnypkVGT6T4s5pEhQ5I= Xref: csiph.com comp.lang.c:93706 Robert Latest 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 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"