Path: csiph.com!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 16:54:55 -0700 Organization: None to speak of Lines: 33 Message-ID: References: <47758107-38f4-9571-76db-1e5991639649@verizon.net> <723258e8-5b49-0399-f34f-c4303ab43584@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="U2FsdGVkX18FAqtQEwlvC4bh2iWUuJxM" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:5+ngBfgsYo+6Zld50UAeDT4DTgM= sha1:FK/8etiWTQjjhA0LE12BL+j5klA= Xref: csiph.com comp.lang.c:93698 "James R. Kuyper" writes: [...] > Here's 100% of what the C standard guarantees about time_t: it is a > "type capable of representing times" (7.27.1p3). In particular, it does > not say anything about HOW it represents time. In particular, it does > not guarantee that it is even an arithmetic type, in which case > subtraction would not even be permitted. It doesn't say anything about > the result from a subtraction of two time_t values would be. C11 requires time_t to be a real type, meaning it's either an integer type or a non-complex floating-point type. C90 and C99 both required it to be an arithmetic type. (As far as I know no C99 implementation took advantage of the permission to make it a complex type.) Everything else you said is correct; subtraction is defined, but it needn't be meaningful. For example, an implementation could plausibly use an integer type with bit sequences used to represent year, month, day, etc., or it could represent the current time (Sat 2016-09-17 21:37:28 UTC) as the integer value 20160917213728. [...] [Speaking of times, the clock on the system I'm posting this from is currently about two hours fast, which affects the timestamps of my articles. I'm doing what I can about it, which is close to nothing.] -- 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"