diff options
author | wes <wes@FreeBSD.org> | 1999-04-25 01:42:18 +0000 |
---|---|---|
committer | wes <wes@FreeBSD.org> | 1999-04-25 01:42:18 +0000 |
commit | 2e0fb29e628fc40dfe18803169033f6ef8a35655 (patch) | |
tree | 73dd570e164f9ed2cffeaa6f23970592697d07f7 | |
parent | 07326e367ccc7586a5b22095d4d7a320b35c8b67 (diff) | |
download | FreeBSD-src-2e0fb29e628fc40dfe18803169033f6ef8a35655.zip FreeBSD-src-2e0fb29e628fc40dfe18803169033f6ef8a35655.tar.gz |
Bring two-digit years up-to-date with POSIX requirements.
70-00 are intepreted in the 20th century; 01-69 in the
21st century. (Yes, 2000 is the last year of the 20th
century, not the first year of the 21st.)
Submitted by: Sergey Babkin <babkin@bellatlantic.net>
-rw-r--r-- | lib/libc/stdtime/strptime.3 | 10 | ||||
-rw-r--r-- | lib/libc/stdtime/strptime.c | 4 |
2 files changed, 12 insertions, 2 deletions
diff --git a/lib/libc/stdtime/strptime.3 b/lib/libc/stdtime/strptime.3 index ac10572..b5dedbe 100644 --- a/lib/libc/stdtime/strptime.3 +++ b/lib/libc/stdtime/strptime.3 @@ -23,7 +23,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.\" $Id: strptime.3,v 1.1 1997/08/09 15:43:54 joerg Exp $ +.\" $Id: strptime.3,v 1.2 1998/09/12 21:13:29 dt Exp $ .\" " .Dd May 8, 1997 .Dt STRPTIME 3 @@ -56,6 +56,14 @@ white space in the format string will match any amount of white space in the buffer. All conversion specifications are identical to those described in .Xr strftime 3 . +.Pp +Two-digit year values, including formats +.Fa %d +and +.Fa %D , +are now interpreted as beginning at 1970 per POSIX requirements. +Years 70-99 are interpreted in the 20th century, years 00-69 in +the 21st century. .Sh RETURN VALUES Upon successful completion, .Fn strptime diff --git a/lib/libc/stdtime/strptime.c b/lib/libc/stdtime/strptime.c index 4c71eaa..f121d68 100644 --- a/lib/libc/stdtime/strptime.c +++ b/lib/libc/stdtime/strptime.c @@ -53,7 +53,7 @@ #ifdef LIBC_RCS static const char rcsid[] = - "$Id: strptime.c,v 1.3 1997/08/13 13:11:53 ache Exp $"; + "$Id: strptime.c,v 1.4 1998/09/12 21:13:29 dt Exp $"; #endif #ifndef lint @@ -333,6 +333,8 @@ strptime(const char *buf, const char *fmt, struct tm *tm) } if (c == 'Y') i -= 1900; + if (c == 'y' && i < 70) + i += 100; if (i < 0) return 0; |