1.\" 2.\" Copyright (c) 1997 Joerg Wunsch 3.\" 4.\" All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 15.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR 16.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, 19.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25.\" 26.\" $FreeBSD$ 27.\" " 28.Dd May 8, 1997 29.Dt STRPTIME 3 30.Os 31.Sh NAME 32.Nm strptime 33.Nd parse date and time string 34.Sh LIBRARY 35.Lb libc 36.Sh SYNOPSIS 37.In time.h 38.Ft char * 39.Fo strptime 40.Fa "const char * restrict buf" 41.Fa "const char * restrict format" 42.Fa "struct tm * restrict timeptr" 43.Fc 44.Sh DESCRIPTION 45The 46.Fn strptime 47function parses the string in the buffer 48.Fa buf 49according to the string pointed to by 50.Fa format , 51and fills in the elements of the structure pointed to by 52.Fa timeptr . 53The resulting values will be relative to the local time zone. 54Thus, it can be considered the reverse operation of 55.Xr strftime 3 . 56.Pp 57The 58.Fa format 59string consists of zero or more conversion specifications and 60ordinary characters. 61All ordinary characters are matched exactly with the buffer, where 62white space in the format string will match any amount of white space 63in the buffer. 64All conversion specifications are identical to those described in 65.Xr strftime 3 . 66.Pp 67Two-digit year values, including formats 68.Fa %y 69and 70.Fa \&%D , 71are now interpreted as beginning at 1969 per POSIX requirements. 72Years 69-00 are interpreted in the 20th century (1969-2000), years 7301-68 in the 21st century (2001-2068). 74.Sh RETURN VALUES 75Upon successful completion, 76.Fn strptime 77returns the pointer to the first character in 78.Fa buf 79that has not been required to satisfy the specified conversions in 80.Fa format . 81It returns 82.Dv NULL 83if one of the conversions failed. 84.Sh SEE ALSO 85.Xr date 1 , 86.Xr scanf 3 , 87.Xr strftime 3 88.Sh AUTHORS 89The 90.Fn strptime 91function has been contributed by Powerdog Industries. 92.Pp 93This man page was written by 94.An J\(:org Wunsch . 95.Sh HISTORY 96The 97.Fn strptime 98function appeared in 99.Fx 3.0 . 100.Sh BUGS 101Both the 102.Fa %e 103and 104.Fa %l 105format specifiers may incorrectly scan one too many digits 106if the intended values comprise only a single digit 107and that digit is followed immediately by another digit. 108Both specifiers accept zero-padded values, 109even though they are both defined as taking unpadded values. 110.Pp 111The 112.Fa %p 113format specifier has no effect unless it is parsed 114.Em after 115hour-related specifiers. 116Specifying 117.Fa %l 118without 119.Fa %p 120will produce undefined results. 121Note that 12AM 122(ante meridiem) 123is taken as midnight 124and 12PM 125(post meridiem) 126is taken as noon. 127.Pp 128The 129.Fa %U 130and 131.Fa %W 132format specifiers accept any value within the range 00 to 53 133without validating against other values supplied (like month 134or day of the year, for example). 135.Pp 136The 137.Fa %Z 138format specifier only accepts time zone abbreviations of the local time zone, 139or the value "GMT". 140This limitation is because of ambiguity due to of the over loading of time 141zone abbreviations. One such example is 142.Fa EST 143which is both Eastern Standard Time and Eastern Australia Summer Time. 144