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.Fn strptime "const char *buf" "const char *format" "struct tm *timeptr" 40.Sh DESCRIPTION 41The 42.Fn strptime 43function parses the string in the buffer 44.Fa buf 45according to the string pointed to by 46.Fa format , 47and fills in the elements of the structure pointed to by 48.Fa timeptr . 49The resulting values will be relative to the local time zone. 50Thus, it can be considered the reverse operation of 51.Xr strftime 3 . 52.Pp 53The 54.Fa format 55string consists of zero or more conversion specifications and 56ordinary characters. 57All ordinary characters are matched exactly with the buffer, where 58white space in the format string will match any amount of white space 59in the buffer. 60All conversion specifications are identical to those described in 61.Xr strftime 3 . 62.Pp 63Two-digit year values, including formats 64.Fa %y 65and 66.Fa \&%D , 67are now interpreted as beginning at 1969 per POSIX requirements. 68Years 69-00 are interpreted in the 20th century (1969-2000), years 6901-68 in the 21st century (2001-2068). 70.Sh RETURN VALUES 71Upon successful completion, 72.Fn strptime 73returns the pointer to the first character in 74.Fa buf 75that has not been required to satisfy the specified conversions in 76.Fa format . 77It returns 78.Dv NULL 79if one of the conversions failed. 80.Sh SEE ALSO 81.Xr date 1 , 82.Xr scanf 3 , 83.Xr strftime 3 84.Sh AUTHORS 85The 86.Fn strptime 87function has been contributed by Powerdog Industries. 88.Pp 89This man page was written by 90.An J\(:org Wunsch . 91.Sh HISTORY 92The 93.Fn strptime 94function appeared in 95.Fx 3.0 . 96.Sh BUGS 97Both the 98.Fa %e 99and 100.Fa %l 101format specifiers may incorrectly scan one too many digits 102if the intended values comprise only a single digit 103and that digit is followed immediately by another digit. 104Both specifiers accept zero-padded values, 105even though they are both defined as taking unpadded values. 106.Pp 107The 108.Fa %p 109format specifier has no effect unless it is parsed 110.Em after 111hour-related specifiers. 112Specifying 113.Fa %l 114without 115.Fa %p 116will produce undefined results. 117Note that 12AM 118(ante meridiem) 119is taken as midnight 120and 12PM 121(post meridiem) 122is taken as noon. 123.Pp 124The 125.Fa %U 126and 127.Fa %W 128format specifiers accept any value within the range 00 to 53 129without validating against other values supplied (like month 130or day of the year, for example). 131.Pp 132The 133.Fa %Z 134format specifier only accepts time zone abbreviations of the local time zone, 135or the value "GMT". 136This limitation is because of ambiguity due to of the over loading of time 137zone abbreviations. One such example is 138.Fa EST 139which is both Eastern Standard Time and Eastern Australia Summer Time. 140