I can't speak for all implementations, but I think glibc offtime() must
be very widely used as it is called by localtime(), gmtime(), mktime()
and others.
Year zero is 62167219200 seconds before 1970 ("the Epoch"):
(1970 * 365 == 719050 + 478 leap year days == 719528 days * 86400s ==
62167219200 seconds)
If you call:
tm tmX;
int64_t i64Secs1970 = -62167219200;
__offtime (i64Secs1970, 0, &tmX);
I believe you will get:
tmX.tm_sec == 0;
tmX.tm_min == 0;
tmX.tm_hour == 0;
tmX.tm_mday == 1;
tmX.tm_mon == 0;
tmX.tm_year == -1900;
tmX.tm_wday == 6;
tmX.tm_yday == 0;
tmX.tm_isdst == 0;
tmX.tm_gmtoff == 0;
which is "0000-01-01 00:00:00".
As far as I call tell offtime() is an air-tight implementation of ISO
8601 (2004) 3.2.1 The Gregorian calendar (without leap-seconds). It
performs the reverse of the formula described in 4.16 Seconds Since the
Epoch of The Open Group Base Specifications Issue 7, 2018 edition. So I
think POSIX itself implies that year zero exists on the proleptic
Gregorian calendar.
If the standard says "Years prior to AD 1 shall be represented as
negative numbers." I think that is inconsistent with the formulas and
typical implementations and should be revised.
I think the suggested "The year prior to 1 CE shall be represented as 0,
preceding years as negative numbers." is misleading. I wonder if the use
of "CE" here is a typo, because the year prior to 1 CE would be -0001
while the year prior to 1 AD would be 0000, isn't that right? That is,
isn't the year prior to 1 AD == 1 CE == 0000?
To nitpick I'd point out that values of time_t are negative prior to
1970 and values of tm.tm_year are negative prior to 1900. The sentence
is referring to the representation of years in proleptic Gregorian, not
time_t or tm.tm_year values. So I might suggest "In the proleptic
Gregorian calendar the year prior to 1 AD shall be represented as 0,
preceding years as negative values.". I suppose it could also
(informatively) state "the value of time_t at year zero is -62167219200
and the value of tm.tm_year is -1900.".
It might also be resolved by simply deleting the sentence. Introducing
AD and/or CE designations may be outside POSIX scope. If used wouldn't
that require a normative reference or definitions of AD and CE?
See also
Year zero
https://en.wikipedia.org/wiki/Year_zero
offtime.c
https://codebrowser.dev/glibc/glibc/time/offtime.c.html
Common Calendar
https://common-calendar.org/
-Brooks Harris
On 2025-02-14 10:26 AM, Andrew Josey via austin-group-l at The Open
Group wrote:
hi All
A question came up yesterday in the meeting on bug 1904 and what
implementations do.
0001904: LC_TIME era start_date (and end_date) possibly mis-specified
https://www.austingroupbugs.net/bug_view_page.php?bug_id=1904
Where the standard says
Years prior to AD 1 shall be represented as negative numbers.
Historically, there was no year 0 and the standard is worded to reflect this
fact.
The question is, is this what implementations actually do?
We’re looking for feedback on what different platforms do.
thanks in advance
regards
Andrew
--------
Andrew Josey The Open Group
Austin Group Chair
Email:[email protected]
Apex Plaza, Forbury Road,Reading,Berks.RG1 1AX,England
To learn how we maintain your privacy, please review The Open Group Privacy
Statement athttp://www.opengroup.org/privacy.
To unsubscribe/opt-out from this mailing list login to The Open Group
collaboration portal at
https://collaboration.opengroup.org/operational/portal.php?action=unsub&listid=2481