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>
This commit is contained in:
parent
19477ba0b7
commit
a00b1d8f7a
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user