Defect Report concerning: IEEE Std. 1003.1-1996, ISO/IEC 9945-1:1996 - C API
Clause: p25, ll 497-498, clause 2.2.2.113
PASC Interpretation Ref: pasc-1003.1-92
Topic: Seconds since the epoch


This is an unapproved interpretation of PASC 1003.1-1996, ISO/IEC 9945-1:1996 - C API.

Use of the information contained in this unapproved document is at your own risk.

Last update: 10 April,2001


								1003.1-96  #92

 _____________________________________________________________________________

	Interpretation Number:	XXXX
	Topic:			Seconds since the epoch
	Relevant Sections:	p25, ll 497-498, clause 2.2.2.113


PASC Interpretation Request: (Defect Report)
----------------------------  

	Date: Fri, 17 Jul 1998 17:16:25 +0100

------------------------------------------------------------------------ 

 7  Defect Report concerning (number and title of International Standard
    or DIS final text, if applicable): 

IEEE Std 1003.1-1996 (incorporates 1003.1-1990, 1003.1b-1993, 1003.1c-1995, 1003.1i-1995) (ISO 9945-1:1996)

------------------------------------------------------------------------ 

 8  Qualifier (e.g. error, omission, clarification required):

1

Error=1 , Omission=2, Clarification=3

------------------------------------------------------------------------ 

 9  References in document (e.g. page, clause, figure, and/or table
    numbers):

p25, ll 497-498, clause 2.2.2.113

------------------------------------------------------------------------ 

10  Nature of defect (complete, concise explanation of the perceived
    problem):


IEEE Std 1003.1-1996 contains an error in section 2.2.2.113 which defines
the term "seconds since the Epoch".  The error is that the expression:

    tm_sec + tm_min*60 + tm_hour*3600 + tm_yday*86400 +
    (tm_year-70)*31536000 + ((tm_year-69)/4)*86400

does not correctly account for leap years.  It adds one day for every
four years, thus disregarding the rule that years divisible by 100 are
only leap years if also divisible by 400.

The expression produces incorrect values for years 2101 onwards, and
so the error could perhaps be called a "Year 2101 bug".  Of course,
this does not affect implementations with a (signed) 32-bit time_t,
which can only represent years up to 2038, and this probably explains
why the necessary extra parts of the expression were omitted in the
original 1988 standard.
------------------------------------------------------------------------ 

11  Solution proposed by the submitter (optional):



I believe a suitable correction is as follows:

    tm_sec + tm_min*60 + tm_hour*3600 + tm_yday*86400 +
    (tm_year-70)*31536000 +
    ((tm_year-69)/4 - (tm_year-1)/100 + (tm_year+299)/400)*86400



------------------------------------------------------------------------ 
Interpretation response:
-----------------------

The standards states the requirements for seconds since the eopch , and 
conforming implementations must conform to this. However, concerns have
been raised about this which are being referred to the sponsor.

Rationale
-------------
None.

Notes to the technical editor (not part of this interpretation)
-----------------------------
The proposed correction in section 11 should be considered for a 
future revision.

Forwarded to Interpretations group: 22 July 1998
Proposed Interpretation: 10 August 1998
Finalised: February 17 1999