History log of /openbsd-current/lib/libc/time/strptime.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.31 02-Mar-2023 millert

When parsing %s, the result should be in the local time zone.
Based on a patch from enh@google. OK tb@


Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.30 12-May-2019 schwarze

Unifdef TM_GMTOFF TM_ZONE USG_COMPAT ALTZONE to make the code more readable.
No binary change when compiled with -g0.
Note that wcsftime.c did not even compile without TM_ZONE.
OK millert@


# 1.29 10-May-2019 schwarze

trim trailing whitespace (reported by Hiltjo Posthuma)
and also delete spaces before tabs;
no object change


# 1.28 10-May-2019 schwarze

repair %z: store seconds into tm_gmtoff, not centihours;
bug reported by Hiltjo Posthuma <hiltjo at codemadness dot org>;
feedback and OK millert@, OK tedu@


# 1.27 10-May-2019 schwarze

repair %Z: write seconds into tm_gmtoff, not hours;
patch from Hiltjo Posthuma <hiltjo at codemadness dot org>;
OK tedu@ millert@


# 1.26 10-May-2019 schwarze

Delete support for military timezones in %z (A-I and K-Y).
They were originally defined in one way, then RFC822 erroneously
redefined them the opposite way, then RFC5322 said they can no
longer be used reliably.
So return NULL like FreeBSD, DragonFly, glibc, and musl do.

Issue reported by Hiltjo Posthuma <hiltjo at codemadness dot org>.
Deletion suggested by tedu@ and deraadt@.
Feedback and OK on the patch from tedu@.


Revision tags: OPENBSD_6_5_BASE
# 1.25 21-Feb-2019 kn

Consume one leading space with %e iff given

Since strftime(3)'s %e conversion specification preceeds single digits by a
blank, do the converse here to allow safe data round trips through these
functions with the same format string.

Positive feedback tedu deraadt,
OK millert jca


# 1.24 22-Jan-2019 cheloha

strptime(3): Disallow double leap second.

POSIX allows for one extra second in a minute, i.e. "23:59:60", so that leap
seconds can be parsed. They don't allow for *two* extra seconds, i.e.
"23:59:61", though.

Typo introduced in NetBSD lib/libc/time/strptime.c,v1.3.

ok krw@ bcook@ tedu@


# 1.23 21-Jan-2019 tedu

strftime can print epoch seconds with %s, so allow strptime to parse it.
ok cheloha


Revision tags: OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.22 23-May-2016 guenther

Stop exposing <sys/localedef.h> and various symbols internal to the libc
locale implementation: _{Current,Default}*Locale, __[mn]locale_changed,
__mb_len_max_runtime

ok millert@ schwarze@ deraadt@


Revision tags: OPENBSD_5_9_BASE
# 1.21 12-Sep-2015 guenther

Wrap <time.h> so that internal calls go direct and symbols not in C99 are weak
Add prototypes to localtime.c for offtime(), time2posix(), posix2time() to
reduce noise with -Wmissing-prototypes
Eliminate unnecessary #includes


Revision tags: OPENBSD_5_8_BASE
# 1.20 07-Apr-2015 millert

Add support for setting tm_zone now that we have the timezone symbol.


Revision tags: OPENBSD_5_7_BASE
# 1.19 09-Feb-2015 tedu

move include lines around a bit


# 1.18 11-Oct-2014 doug

Add UTC support to %Z conversion in strptime().

Patch from jmates at ee dot washington dot edu.

ok otto@, millert@


# 1.17 02-Oct-2014 doug

Fix a crash when there is text after a failed %Z conversion in strptime.

jmates at ee dot washington dot edu reported this bug and provided a patch.
This is a slightly modified version of the patch that only contains the
bug fix.

ok millert@, otto@


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.16 13-Feb-2014 millert

Fix logic bug; we can only infer tm_yday if both tm_mday and tm_mon
are set. Adapted from a diff from David Higgs. OK krw@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.15 16-Jan-2012 millert

POSIX indicates that some fields should be computed even if not
explicitly set. We can compute tm_yday, tm_wday, tm_mon and tm_mday
based on the values that were specified if possible. Some logic
borrowed from localtime.c. OK espie@ deraadt@


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.14 19-Jan-2011 landry

Fix typo, %F pattern corresponds to %Y-%m-%d (the ISO 8601 date format),
not %Y/%m/%d. Found while debugging geo/gpx-viewer.
ok millert@ jasper@


# 1.13 08-Nov-2010 jasper

Add %F, %g, %G, %u, %z (extended) and %Z.
This is mostly a sync with NetBSD.

tested in a bulk build by landry@
ok millert@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.12 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.11 08-Aug-2005 espie

zap remaining rcsid.

Kill old files that are no longer compiled.

okay theo


Revision tags: OPENBSD_3_7_BASE
# 1.10 15-Sep-2004 deraadt

signed vs unsigned char casting...


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE
# 1.9 20-Jan-2004 millert

Stop parsing the buffer after an appropriate number of digits; from NetBSD
OK otto@ and miod@


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE OPENBSD_3_4_BASE
# 1.8 16-Feb-2002 millert

branches: 1.8.6; 1.8.8;
Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


Revision tags: OPENBSD_3_0_BASE
# 1.7 23-Aug-2001 espie

Kill very odd use of __CONCAT: completely unneeded, obfuscated, and
not even ANSI (concatenation does not produce a valid token).

Found out by heko@.


Revision tags: OPENBSD_2_9_BASE
# 1.6 08-Jan-2001 d

fix %p matching. checked by angelos. closes PR1612


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.5 25-Apr-1998 deraadt

month/weekday names are case insensitive; jpo@EasternGraphics.com


Revision tags: OPENBSD_2_3_BASE
# 1.4 17-Mar-1998 millert

Make %Y override an earlier %y (%y stuff gets delayed due to century specs).


# 1.3 15-Mar-1998 millert

%C influences %y regardless of ordering. This becomes a bit tricky
due to recursion so we do all the work in _strptime which takes
an extra flag specifying whether or not to initialize some statics.


# 1.2 15-Mar-1998 millert

Fix %m, %I, %S, %y, %C, and %j conversions. Fixes by nakayosh@kcn.or.jp
and myself. Some bugs noted by woods@most.weird.com.


# 1.1 04-Feb-1998 deraadt

+ strptime, from netbsd


# 1.30 12-May-2019 schwarze

Unifdef TM_GMTOFF TM_ZONE USG_COMPAT ALTZONE to make the code more readable.
No binary change when compiled with -g0.
Note that wcsftime.c did not even compile without TM_ZONE.
OK millert@


# 1.29 10-May-2019 schwarze

trim trailing whitespace (reported by Hiltjo Posthuma)
and also delete spaces before tabs;
no object change


# 1.28 10-May-2019 schwarze

repair %z: store seconds into tm_gmtoff, not centihours;
bug reported by Hiltjo Posthuma <hiltjo at codemadness dot org>;
feedback and OK millert@, OK tedu@


# 1.27 10-May-2019 schwarze

repair %Z: write seconds into tm_gmtoff, not hours;
patch from Hiltjo Posthuma <hiltjo at codemadness dot org>;
OK tedu@ millert@


# 1.26 10-May-2019 schwarze

Delete support for military timezones in %z (A-I and K-Y).
They were originally defined in one way, then RFC822 erroneously
redefined them the opposite way, then RFC5322 said they can no
longer be used reliably.
So return NULL like FreeBSD, DragonFly, glibc, and musl do.

Issue reported by Hiltjo Posthuma <hiltjo at codemadness dot org>.
Deletion suggested by tedu@ and deraadt@.
Feedback and OK on the patch from tedu@.


Revision tags: OPENBSD_6_5_BASE
# 1.25 21-Feb-2019 kn

Consume one leading space with %e iff given

Since strftime(3)'s %e conversion specification preceeds single digits by a
blank, do the converse here to allow safe data round trips through these
functions with the same format string.

Positive feedback tedu deraadt,
OK millert jca


# 1.24 22-Jan-2019 cheloha

strptime(3): Disallow double leap second.

POSIX allows for one extra second in a minute, i.e. "23:59:60", so that leap
seconds can be parsed. They don't allow for *two* extra seconds, i.e.
"23:59:61", though.

Typo introduced in NetBSD lib/libc/time/strptime.c,v1.3.

ok krw@ bcook@ tedu@


# 1.23 21-Jan-2019 tedu

strftime can print epoch seconds with %s, so allow strptime to parse it.
ok cheloha


Revision tags: OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.22 23-May-2016 guenther

Stop exposing <sys/localedef.h> and various symbols internal to the libc
locale implementation: _{Current,Default}*Locale, __[mn]locale_changed,
__mb_len_max_runtime

ok millert@ schwarze@ deraadt@


Revision tags: OPENBSD_5_9_BASE
# 1.21 12-Sep-2015 guenther

Wrap <time.h> so that internal calls go direct and symbols not in C99 are weak
Add prototypes to localtime.c for offtime(), time2posix(), posix2time() to
reduce noise with -Wmissing-prototypes
Eliminate unnecessary #includes


Revision tags: OPENBSD_5_8_BASE
# 1.20 07-Apr-2015 millert

Add support for setting tm_zone now that we have the timezone symbol.


Revision tags: OPENBSD_5_7_BASE
# 1.19 09-Feb-2015 tedu

move include lines around a bit


# 1.18 11-Oct-2014 doug

Add UTC support to %Z conversion in strptime().

Patch from jmates at ee dot washington dot edu.

ok otto@, millert@


# 1.17 02-Oct-2014 doug

Fix a crash when there is text after a failed %Z conversion in strptime.

jmates at ee dot washington dot edu reported this bug and provided a patch.
This is a slightly modified version of the patch that only contains the
bug fix.

ok millert@, otto@


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.16 13-Feb-2014 millert

Fix logic bug; we can only infer tm_yday if both tm_mday and tm_mon
are set. Adapted from a diff from David Higgs. OK krw@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.15 16-Jan-2012 millert

POSIX indicates that some fields should be computed even if not
explicitly set. We can compute tm_yday, tm_wday, tm_mon and tm_mday
based on the values that were specified if possible. Some logic
borrowed from localtime.c. OK espie@ deraadt@


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.14 19-Jan-2011 landry

Fix typo, %F pattern corresponds to %Y-%m-%d (the ISO 8601 date format),
not %Y/%m/%d. Found while debugging geo/gpx-viewer.
ok millert@ jasper@


# 1.13 08-Nov-2010 jasper

Add %F, %g, %G, %u, %z (extended) and %Z.
This is mostly a sync with NetBSD.

tested in a bulk build by landry@
ok millert@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.12 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.11 08-Aug-2005 espie

zap remaining rcsid.

Kill old files that are no longer compiled.

okay theo


Revision tags: OPENBSD_3_7_BASE
# 1.10 15-Sep-2004 deraadt

signed vs unsigned char casting...


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE
# 1.9 20-Jan-2004 millert

Stop parsing the buffer after an appropriate number of digits; from NetBSD
OK otto@ and miod@


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE OPENBSD_3_4_BASE
# 1.8 16-Feb-2002 millert

branches: 1.8.6; 1.8.8;
Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


Revision tags: OPENBSD_3_0_BASE
# 1.7 23-Aug-2001 espie

Kill very odd use of __CONCAT: completely unneeded, obfuscated, and
not even ANSI (concatenation does not produce a valid token).

Found out by heko@.


Revision tags: OPENBSD_2_9_BASE
# 1.6 08-Jan-2001 d

fix %p matching. checked by angelos. closes PR1612


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.5 25-Apr-1998 deraadt

month/weekday names are case insensitive; jpo@EasternGraphics.com


Revision tags: OPENBSD_2_3_BASE
# 1.4 17-Mar-1998 millert

Make %Y override an earlier %y (%y stuff gets delayed due to century specs).


# 1.3 15-Mar-1998 millert

%C influences %y regardless of ordering. This becomes a bit tricky
due to recursion so we do all the work in _strptime which takes
an extra flag specifying whether or not to initialize some statics.


# 1.2 15-Mar-1998 millert

Fix %m, %I, %S, %y, %C, and %j conversions. Fixes by nakayosh@kcn.or.jp
and myself. Some bugs noted by woods@most.weird.com.


# 1.1 04-Feb-1998 deraadt

+ strptime, from netbsd


# 1.29 10-May-2019 schwarze

trim trailing whitespace (reported by Hiltjo Posthuma)
and also delete spaces before tabs;
no object change


# 1.28 10-May-2019 schwarze

repair %z: store seconds into tm_gmtoff, not centihours;
bug reported by Hiltjo Posthuma <hiltjo at codemadness dot org>;
feedback and OK millert@, OK tedu@


# 1.27 10-May-2019 schwarze

repair %Z: write seconds into tm_gmtoff, not hours;
patch from Hiltjo Posthuma <hiltjo at codemadness dot org>;
OK tedu@ millert@


# 1.26 10-May-2019 schwarze

Delete support for military timezones in %z (A-I and K-Y).
They were originally defined in one way, then RFC822 erroneously
redefined them the opposite way, then RFC5322 said they can no
longer be used reliably.
So return NULL like FreeBSD, DragonFly, glibc, and musl do.

Issue reported by Hiltjo Posthuma <hiltjo at codemadness dot org>.
Deletion suggested by tedu@ and deraadt@.
Feedback and OK on the patch from tedu@.


Revision tags: OPENBSD_6_5_BASE
# 1.25 21-Feb-2019 kn

Consume one leading space with %e iff given

Since strftime(3)'s %e conversion specification preceeds single digits by a
blank, do the converse here to allow safe data round trips through these
functions with the same format string.

Positive feedback tedu deraadt,
OK millert jca


# 1.24 22-Jan-2019 cheloha

strptime(3): Disallow double leap second.

POSIX allows for one extra second in a minute, i.e. "23:59:60", so that leap
seconds can be parsed. They don't allow for *two* extra seconds, i.e.
"23:59:61", though.

Typo introduced in NetBSD lib/libc/time/strptime.c,v1.3.

ok krw@ bcook@ tedu@


# 1.23 21-Jan-2019 tedu

strftime can print epoch seconds with %s, so allow strptime to parse it.
ok cheloha


Revision tags: OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.22 23-May-2016 guenther

Stop exposing <sys/localedef.h> and various symbols internal to the libc
locale implementation: _{Current,Default}*Locale, __[mn]locale_changed,
__mb_len_max_runtime

ok millert@ schwarze@ deraadt@


Revision tags: OPENBSD_5_9_BASE
# 1.21 12-Sep-2015 guenther

Wrap <time.h> so that internal calls go direct and symbols not in C99 are weak
Add prototypes to localtime.c for offtime(), time2posix(), posix2time() to
reduce noise with -Wmissing-prototypes
Eliminate unnecessary #includes


Revision tags: OPENBSD_5_8_BASE
# 1.20 07-Apr-2015 millert

Add support for setting tm_zone now that we have the timezone symbol.


Revision tags: OPENBSD_5_7_BASE
# 1.19 09-Feb-2015 tedu

move include lines around a bit


# 1.18 11-Oct-2014 doug

Add UTC support to %Z conversion in strptime().

Patch from jmates at ee dot washington dot edu.

ok otto@, millert@


# 1.17 02-Oct-2014 doug

Fix a crash when there is text after a failed %Z conversion in strptime.

jmates at ee dot washington dot edu reported this bug and provided a patch.
This is a slightly modified version of the patch that only contains the
bug fix.

ok millert@, otto@


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.16 13-Feb-2014 millert

Fix logic bug; we can only infer tm_yday if both tm_mday and tm_mon
are set. Adapted from a diff from David Higgs. OK krw@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.15 16-Jan-2012 millert

POSIX indicates that some fields should be computed even if not
explicitly set. We can compute tm_yday, tm_wday, tm_mon and tm_mday
based on the values that were specified if possible. Some logic
borrowed from localtime.c. OK espie@ deraadt@


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.14 19-Jan-2011 landry

Fix typo, %F pattern corresponds to %Y-%m-%d (the ISO 8601 date format),
not %Y/%m/%d. Found while debugging geo/gpx-viewer.
ok millert@ jasper@


# 1.13 08-Nov-2010 jasper

Add %F, %g, %G, %u, %z (extended) and %Z.
This is mostly a sync with NetBSD.

tested in a bulk build by landry@
ok millert@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.12 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.11 08-Aug-2005 espie

zap remaining rcsid.

Kill old files that are no longer compiled.

okay theo


Revision tags: OPENBSD_3_7_BASE
# 1.10 15-Sep-2004 deraadt

signed vs unsigned char casting...


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE
# 1.9 20-Jan-2004 millert

Stop parsing the buffer after an appropriate number of digits; from NetBSD
OK otto@ and miod@


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE OPENBSD_3_4_BASE
# 1.8 16-Feb-2002 millert

branches: 1.8.6; 1.8.8;
Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


Revision tags: OPENBSD_3_0_BASE
# 1.7 23-Aug-2001 espie

Kill very odd use of __CONCAT: completely unneeded, obfuscated, and
not even ANSI (concatenation does not produce a valid token).

Found out by heko@.


Revision tags: OPENBSD_2_9_BASE
# 1.6 08-Jan-2001 d

fix %p matching. checked by angelos. closes PR1612


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.5 25-Apr-1998 deraadt

month/weekday names are case insensitive; jpo@EasternGraphics.com


Revision tags: OPENBSD_2_3_BASE
# 1.4 17-Mar-1998 millert

Make %Y override an earlier %y (%y stuff gets delayed due to century specs).


# 1.3 15-Mar-1998 millert

%C influences %y regardless of ordering. This becomes a bit tricky
due to recursion so we do all the work in _strptime which takes
an extra flag specifying whether or not to initialize some statics.


# 1.2 15-Mar-1998 millert

Fix %m, %I, %S, %y, %C, and %j conversions. Fixes by nakayosh@kcn.or.jp
and myself. Some bugs noted by woods@most.weird.com.


# 1.1 04-Feb-1998 deraadt

+ strptime, from netbsd


# 1.25 21-Feb-2019 kn

Consume one leading space with %e iff given

Since strftime(3)'s %e conversion specification preceeds single digits by a
blank, do the converse here to allow safe data round trips through these
functions with the same format string.

Positive feedback tedu deraadt,
OK millert jca


# 1.24 22-Jan-2019 cheloha

strptime(3): Disallow double leap second.

POSIX allows for one extra second in a minute, i.e. "23:59:60", so that leap
seconds can be parsed. They don't allow for *two* extra seconds, i.e.
"23:59:61", though.

Typo introduced in NetBSD lib/libc/time/strptime.c,v1.3.

ok krw@ bcook@ tedu@


# 1.23 21-Jan-2019 tedu

strftime can print epoch seconds with %s, so allow strptime to parse it.
ok cheloha


Revision tags: OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.22 23-May-2016 guenther

Stop exposing <sys/localedef.h> and various symbols internal to the libc
locale implementation: _{Current,Default}*Locale, __[mn]locale_changed,
__mb_len_max_runtime

ok millert@ schwarze@ deraadt@


Revision tags: OPENBSD_5_9_BASE
# 1.21 12-Sep-2015 guenther

Wrap <time.h> so that internal calls go direct and symbols not in C99 are weak
Add prototypes to localtime.c for offtime(), time2posix(), posix2time() to
reduce noise with -Wmissing-prototypes
Eliminate unnecessary #includes


Revision tags: OPENBSD_5_8_BASE
# 1.20 07-Apr-2015 millert

Add support for setting tm_zone now that we have the timezone symbol.


Revision tags: OPENBSD_5_7_BASE
# 1.19 09-Feb-2015 tedu

move include lines around a bit


# 1.18 11-Oct-2014 doug

Add UTC support to %Z conversion in strptime().

Patch from jmates at ee dot washington dot edu.

ok otto@, millert@


# 1.17 02-Oct-2014 doug

Fix a crash when there is text after a failed %Z conversion in strptime.

jmates at ee dot washington dot edu reported this bug and provided a patch.
This is a slightly modified version of the patch that only contains the
bug fix.

ok millert@, otto@


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.16 13-Feb-2014 millert

Fix logic bug; we can only infer tm_yday if both tm_mday and tm_mon
are set. Adapted from a diff from David Higgs. OK krw@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.15 16-Jan-2012 millert

POSIX indicates that some fields should be computed even if not
explicitly set. We can compute tm_yday, tm_wday, tm_mon and tm_mday
based on the values that were specified if possible. Some logic
borrowed from localtime.c. OK espie@ deraadt@


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.14 19-Jan-2011 landry

Fix typo, %F pattern corresponds to %Y-%m-%d (the ISO 8601 date format),
not %Y/%m/%d. Found while debugging geo/gpx-viewer.
ok millert@ jasper@


# 1.13 08-Nov-2010 jasper

Add %F, %g, %G, %u, %z (extended) and %Z.
This is mostly a sync with NetBSD.

tested in a bulk build by landry@
ok millert@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.12 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.11 08-Aug-2005 espie

zap remaining rcsid.

Kill old files that are no longer compiled.

okay theo


Revision tags: OPENBSD_3_7_BASE
# 1.10 15-Sep-2004 deraadt

signed vs unsigned char casting...


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE
# 1.9 20-Jan-2004 millert

Stop parsing the buffer after an appropriate number of digits; from NetBSD
OK otto@ and miod@


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE OPENBSD_3_4_BASE
# 1.8 16-Feb-2002 millert

branches: 1.8.6; 1.8.8;
Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


Revision tags: OPENBSD_3_0_BASE
# 1.7 23-Aug-2001 espie

Kill very odd use of __CONCAT: completely unneeded, obfuscated, and
not even ANSI (concatenation does not produce a valid token).

Found out by heko@.


Revision tags: OPENBSD_2_9_BASE
# 1.6 08-Jan-2001 d

fix %p matching. checked by angelos. closes PR1612


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.5 25-Apr-1998 deraadt

month/weekday names are case insensitive; jpo@EasternGraphics.com


Revision tags: OPENBSD_2_3_BASE
# 1.4 17-Mar-1998 millert

Make %Y override an earlier %y (%y stuff gets delayed due to century specs).


# 1.3 15-Mar-1998 millert

%C influences %y regardless of ordering. This becomes a bit tricky
due to recursion so we do all the work in _strptime which takes
an extra flag specifying whether or not to initialize some statics.


# 1.2 15-Mar-1998 millert

Fix %m, %I, %S, %y, %C, and %j conversions. Fixes by nakayosh@kcn.or.jp
and myself. Some bugs noted by woods@most.weird.com.


# 1.1 04-Feb-1998 deraadt

+ strptime, from netbsd


# 1.24 22-Jan-2019 cheloha

strptime(3): Disallow double leap second.

POSIX allows for one extra second in a minute, i.e. "23:59:60", so that leap
seconds can be parsed. They don't allow for *two* extra seconds, i.e.
"23:59:61", though.

Typo introduced in NetBSD lib/libc/time/strptime.c,v1.3.

ok krw@ bcook@ tedu@


# 1.23 21-Jan-2019 tedu

strftime can print epoch seconds with %s, so allow strptime to parse it.
ok cheloha


Revision tags: OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.22 23-May-2016 guenther

Stop exposing <sys/localedef.h> and various symbols internal to the libc
locale implementation: _{Current,Default}*Locale, __[mn]locale_changed,
__mb_len_max_runtime

ok millert@ schwarze@ deraadt@


Revision tags: OPENBSD_5_9_BASE
# 1.21 12-Sep-2015 guenther

Wrap <time.h> so that internal calls go direct and symbols not in C99 are weak
Add prototypes to localtime.c for offtime(), time2posix(), posix2time() to
reduce noise with -Wmissing-prototypes
Eliminate unnecessary #includes


Revision tags: OPENBSD_5_8_BASE
# 1.20 07-Apr-2015 millert

Add support for setting tm_zone now that we have the timezone symbol.


Revision tags: OPENBSD_5_7_BASE
# 1.19 09-Feb-2015 tedu

move include lines around a bit


# 1.18 11-Oct-2014 doug

Add UTC support to %Z conversion in strptime().

Patch from jmates at ee dot washington dot edu.

ok otto@, millert@


# 1.17 02-Oct-2014 doug

Fix a crash when there is text after a failed %Z conversion in strptime.

jmates at ee dot washington dot edu reported this bug and provided a patch.
This is a slightly modified version of the patch that only contains the
bug fix.

ok millert@, otto@


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.16 13-Feb-2014 millert

Fix logic bug; we can only infer tm_yday if both tm_mday and tm_mon
are set. Adapted from a diff from David Higgs. OK krw@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.15 16-Jan-2012 millert

POSIX indicates that some fields should be computed even if not
explicitly set. We can compute tm_yday, tm_wday, tm_mon and tm_mday
based on the values that were specified if possible. Some logic
borrowed from localtime.c. OK espie@ deraadt@


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.14 19-Jan-2011 landry

Fix typo, %F pattern corresponds to %Y-%m-%d (the ISO 8601 date format),
not %Y/%m/%d. Found while debugging geo/gpx-viewer.
ok millert@ jasper@


# 1.13 08-Nov-2010 jasper

Add %F, %g, %G, %u, %z (extended) and %Z.
This is mostly a sync with NetBSD.

tested in a bulk build by landry@
ok millert@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.12 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.11 08-Aug-2005 espie

zap remaining rcsid.

Kill old files that are no longer compiled.

okay theo


Revision tags: OPENBSD_3_7_BASE
# 1.10 15-Sep-2004 deraadt

signed vs unsigned char casting...


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE
# 1.9 20-Jan-2004 millert

Stop parsing the buffer after an appropriate number of digits; from NetBSD
OK otto@ and miod@


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE OPENBSD_3_4_BASE
# 1.8 16-Feb-2002 millert

branches: 1.8.6; 1.8.8;
Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


Revision tags: OPENBSD_3_0_BASE
# 1.7 23-Aug-2001 espie

Kill very odd use of __CONCAT: completely unneeded, obfuscated, and
not even ANSI (concatenation does not produce a valid token).

Found out by heko@.


Revision tags: OPENBSD_2_9_BASE
# 1.6 08-Jan-2001 d

fix %p matching. checked by angelos. closes PR1612


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.5 25-Apr-1998 deraadt

month/weekday names are case insensitive; jpo@EasternGraphics.com


Revision tags: OPENBSD_2_3_BASE
# 1.4 17-Mar-1998 millert

Make %Y override an earlier %y (%y stuff gets delayed due to century specs).


# 1.3 15-Mar-1998 millert

%C influences %y regardless of ordering. This becomes a bit tricky
due to recursion so we do all the work in _strptime which takes
an extra flag specifying whether or not to initialize some statics.


# 1.2 15-Mar-1998 millert

Fix %m, %I, %S, %y, %C, and %j conversions. Fixes by nakayosh@kcn.or.jp
and myself. Some bugs noted by woods@most.weird.com.


# 1.1 04-Feb-1998 deraadt

+ strptime, from netbsd


Revision tags: OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.22 23-May-2016 guenther

Stop exposing <sys/localedef.h> and various symbols internal to the libc
locale implementation: _{Current,Default}*Locale, __[mn]locale_changed,
__mb_len_max_runtime

ok millert@ schwarze@ deraadt@


Revision tags: OPENBSD_5_9_BASE
# 1.21 12-Sep-2015 guenther

Wrap <time.h> so that internal calls go direct and symbols not in C99 are weak
Add prototypes to localtime.c for offtime(), time2posix(), posix2time() to
reduce noise with -Wmissing-prototypes
Eliminate unnecessary #includes


Revision tags: OPENBSD_5_8_BASE
# 1.20 07-Apr-2015 millert

Add support for setting tm_zone now that we have the timezone symbol.


Revision tags: OPENBSD_5_7_BASE
# 1.19 09-Feb-2015 tedu

move include lines around a bit


# 1.18 11-Oct-2014 doug

Add UTC support to %Z conversion in strptime().

Patch from jmates at ee dot washington dot edu.

ok otto@, millert@


# 1.17 02-Oct-2014 doug

Fix a crash when there is text after a failed %Z conversion in strptime.

jmates at ee dot washington dot edu reported this bug and provided a patch.
This is a slightly modified version of the patch that only contains the
bug fix.

ok millert@, otto@


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.16 13-Feb-2014 millert

Fix logic bug; we can only infer tm_yday if both tm_mday and tm_mon
are set. Adapted from a diff from David Higgs. OK krw@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.15 16-Jan-2012 millert

POSIX indicates that some fields should be computed even if not
explicitly set. We can compute tm_yday, tm_wday, tm_mon and tm_mday
based on the values that were specified if possible. Some logic
borrowed from localtime.c. OK espie@ deraadt@


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.14 19-Jan-2011 landry

Fix typo, %F pattern corresponds to %Y-%m-%d (the ISO 8601 date format),
not %Y/%m/%d. Found while debugging geo/gpx-viewer.
ok millert@ jasper@


# 1.13 08-Nov-2010 jasper

Add %F, %g, %G, %u, %z (extended) and %Z.
This is mostly a sync with NetBSD.

tested in a bulk build by landry@
ok millert@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.12 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.11 08-Aug-2005 espie

zap remaining rcsid.

Kill old files that are no longer compiled.

okay theo


Revision tags: OPENBSD_3_7_BASE
# 1.10 15-Sep-2004 deraadt

signed vs unsigned char casting...


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE
# 1.9 20-Jan-2004 millert

Stop parsing the buffer after an appropriate number of digits; from NetBSD
OK otto@ and miod@


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE OPENBSD_3_4_BASE
# 1.8 16-Feb-2002 millert

branches: 1.8.6; 1.8.8;
Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


Revision tags: OPENBSD_3_0_BASE
# 1.7 23-Aug-2001 espie

Kill very odd use of __CONCAT: completely unneeded, obfuscated, and
not even ANSI (concatenation does not produce a valid token).

Found out by heko@.


Revision tags: OPENBSD_2_9_BASE
# 1.6 08-Jan-2001 d

fix %p matching. checked by angelos. closes PR1612


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.5 25-Apr-1998 deraadt

month/weekday names are case insensitive; jpo@EasternGraphics.com


Revision tags: OPENBSD_2_3_BASE
# 1.4 17-Mar-1998 millert

Make %Y override an earlier %y (%y stuff gets delayed due to century specs).


# 1.3 15-Mar-1998 millert

%C influences %y regardless of ordering. This becomes a bit tricky
due to recursion so we do all the work in _strptime which takes
an extra flag specifying whether or not to initialize some statics.


# 1.2 15-Mar-1998 millert

Fix %m, %I, %S, %y, %C, and %j conversions. Fixes by nakayosh@kcn.or.jp
and myself. Some bugs noted by woods@most.weird.com.


# 1.1 04-Feb-1998 deraadt

+ strptime, from netbsd