2 .\" Copyright 2014 Garrett D'Amore <garrett@damore.org>
3 .\" Copyright (c) 1992, X/Open Company Limited. All Rights Reserved.
4 .\" Portions Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved.
5 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
6 .\" http://www.opengroup.org/bookstore/.
7 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
8 .\" This notice shall appear on any product containing this material.
9 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
10 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
11 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
12 .TH STRPTIME 3C "Jun 27, 2014"
14 strptime, strptime_l \- date and time conversion
20 \fBchar *\fR\fBstrptime\fR(\fBconst char *restrict\fR \fIbuf\fR,
21 \fBconst char *restrict\fR \fIformat\fR, \fBstruct tm *restrict\fR \fItm\fR);
28 \fBchar *\fR\fBstrptime_l\fR(\fBconst char *restrict\fR \fIbuf\fR,
29 \fBconst char *restrict\fR \fIformat\fR, \fBstruct tm *restrict\fR \fItm\fR,
30 \fBlocale_t\fR \fIloc\fR);
32 .SS "Non-zeroing Behavior"
35 \fBcc\fR [\fIflag\fR...] \fIfile\fR... \fB-D_STRPTIME_DONTZERO\fR [\fIlibrary\fR...]
38 \fBchar *\fR\fBstrptime\fR(\fBconst char *restrict\fR \fIbuf\fR,
39 \fBconst char *restrict\fR \fIformat\fR, \fBstruct tm *restrict\fR \fItm\fR);
44 The \fBstrptime()\fR function converts the character string pointed to by
45 \fIbuf\fR to values which are stored in the \fBtm\fR structure pointed to by
46 \fItm\fR, using the format specified by \fIformat\fR. The \fBstrptime_l()\fR
47 function is identical to \fBstrptime()\fR except instead of acting in the
48 current locale, it acts in the locale specified by the argument \fIloc\fR.
50 The \fIformat\fR argument is composed of zero or more conversion
51 specifications. Each conversion specification is composed of a "%" (percent)
52 character followed by one or two conversion characters which specify the
53 replacement required. One or more white space characters (as specified by
54 \fBisspace\fR(3C)) may precede or follow a conversion specification. There must
55 be white-space or other non-alphanumeric characters between any two conversion
58 A non-zeroing version of \fBstrptime()\fR, described below under \fBNon-zeroing
59 Behavior\fR, is provided if \fB_STRPTIME_DONTZERO\fR is defined.
60 .SS "Conversion Specifications"
62 The following conversion specifications are supported:
78 Day of week, using the locale's weekday names; either the abbreviated or full
79 name may be specified.
97 Month, using the locale's month names; either the abbreviated or full name may
116 Locale's appropriate date and time representation.
125 Century number (the year divided by 100 and truncated to an integer as a
126 decimal number [1,99]); single digits are preceded by 0. If \fB%C\fR is used
127 without the \fB%y\fR specifier, \fBstrptime()\fR assumes the year offset is
128 zero in whichever century is specified. Note the behavior of \fB%C\fR in the
129 absence of \fB%y\fR is not specified by any of the standards or specifications
130 described on the \fBstandards\fR(5) manual page, so portable applications
131 should not depend on it. This behavior may change in a future release.
140 Day of month [1,31]; leading zero is permitted but not required.
149 Date as \fB%m\fR/\fB%d\fR/\fB%y\fR.
176 Hour (24-hour clock) [0,23]; leading zero is permitted but not required.
185 Hour (12-hour clock) [1,12]; leading zero is permitted but not required.
194 Day number of the year [1,366]; leading zeros are permitted but not required.
203 Month number [1,12]; leading zero is permitted but not required.
212 Minute [0-59]; leading zero is permitted but not required.
230 Locale's equivalent of either a.m. or p.m.
239 Appropriate time representation in the 12-hour clock format with \fB%p\fR.
248 Time as \fB%H\fR:\fB%M\fR.
258 Seconds [0,60]; leading zero is permitted but not required. The range of values
259 is [00,60] rather than [00,59] to allow for the occasional leap second.
262 .SS "Default and other standards"
269 Seconds [0,61]; leading zero is permitted but not required. The range of values
270 is [00,61] rather than [00,59] to allow for the occasional leap second and even
271 more occasional double leap second.
289 Time as \fB%H\fR:\fB%M\fR:\fB%S\fR.
298 Week number of the year as a decimal number [0,53], with Sunday as the first
299 day of the week; leading zero is permitted but not required.
308 Weekday as a decimal number [0,6], with 0 representing Sunday.
317 Week number of the year as a decimal number [0,53], with Monday as the first
318 day of the week; leading zero is permitted but not required.
327 Locale's appropriate date representation.
336 Locale's appropriate time representation.
345 Year within century. When a century is not otherwise specified, values in the
346 range 69-99 refer to years in the twentieth century (1969 to 1999 inclusive);
347 values in the range 00-68 refer to years in the twenty-first century (2000 to
357 Year, including the century (for example, 1993).
366 Time zone name or no characters if no time zone exists.
369 .SS "Modified Conversion Specifications"
371 Some conversion specifications can be modified by the \fBE\fR and \fBO\fR
372 modifier characters to indicate that an alternate format or specification
373 should be used rather than the one normally used by the unmodified
374 specification. If the alternate format or specification does not exist in the
375 current locale, the behavior will be as if the unmodified conversion
376 specification were used.
383 Locale's alternate appropriate date and time representation.
392 Name of the base year (era) in the locale's alternate representation.
401 Locale's alternate date representation.
410 Locale's alternate time representation.
419 Offset from \fB%EC\fR (year only) in the locale's alternate representation.
428 Full alternate year representation.
437 Day of the month using the locale's alternate numeric symbols.
455 Hour (24-hour clock) using the locale's alternate numeric symbols.
464 Hour (12-hour clock) using the locale's alternate numeric symbols.
473 Month using the locale's alternate numeric symbols.
482 Minutes using the locale's alternate numeric symbols.
491 Seconds using the locale's alternate numeric symbols.
500 Week number of the year (Sunday as the first day of the week) using the
501 locale's alternate numeric symbols.
510 Number of the weekday (Sunday=0) using the locale's alternate numeric symbols.
519 Week number of the year (Monday as the first day of the week) using the
520 locale's alternate numeric symbols.
529 Year (offset from \fB%C\fR) in the locale's alternate representation and using
530 the locale's alternate numeric symbols.
533 .SS "General Specifications"
535 A conversion specification that is an ordinary character is executed by
536 scanning the next character from the buffer. If the character scanned from the
537 buffer differs from the one comprising the specification, the specification
538 fails, and the differing and subsequent characters remain unscanned.
541 A series of specifications composed of \fB%n\fR, \fB%t\fR, white-space
542 characters or any combination is executed by scanning up to the first character
543 that is not white space (which remains unscanned), or until no more characters
544 can be scanned. White space is defined by \fBisspace\fR(3C).
546 Any other conversion specification is executed by scanning characters until a
547 character matching the next specification is scanned, or until no more
548 characters can be scanned. These characters, except the one matching the next
549 specification, are then compared to the locale values associated with the
550 conversion specifier. If a match is found, values for the appropriate
551 \fItm\fR structure members are set to values corresponding to the locale
552 information. If no match is found, \fBstrptime()\fR fails and no more
553 characters are scanned.
556 The month names, weekday names, era names, and alternate numeric symbols can
557 consist of any combination of upper and lower case letters. The user can
558 request that the input date or time specification be in a specific language by
559 setting the \fBLC_TIME\fR category using \fBsetlocale\fR(3C).
560 .SS "Non-zeroing Behavior"
562 In addition to the behavior described above by various standards, the Solaris
563 implementation of \fBstrptime()\fR provides the following extensions. These may
564 change at any time in the future. Portable applications should not depend on
565 these extended features:
570 If \fB_STRPTIME_DONTZERO\fR is not defined, the \fBtm struct\fR is zeroed on
571 entry and \fBstrptime()\fR updates the fields of the \fBtm struct\fR associated
572 with the specifiers in the format string.
578 If \fB_STRPTIME_DONTZERO\fR is defined, \fBstrptime()\fR does not zero the
579 \fBtm struct\fR on entry. Additionally, for some specifiers, \fBstrptime()\fR
580 will use some values in the input \fBtm struct\fR to recalculate the date and
581 re-assign the appropriate members of the \fBtm struct\fR.
584 The following describes extended features regardless of whether
585 \fB_STRPTIME_DONTZERO\fR is defined or not defined:
590 If \fB%j\fR is specified, \fBtm_yday\fR is set; if year is given, and if month
591 and day are not given, \fBstrptime()\fR calculates and sets \fBtm_mon\fR,
592 \fBtm_mday\fR, and \fBtm_year\fR.
598 If \fB%U\fR or \fB%W\fR is specified and if weekday and year are given and
599 month and day of month are not given, \fBstrptime()\fR calculates and sets
600 \fBtm_mon\fR, \fBtm_mday\fR, \fBtm_wday\fR, and \fBtm_year\fR.
603 The following describes extended features when \fB_STRPTIME_DONTZERO\fR is not
609 If \fB%C\fR is specified and \fB%y\fR is not specified, \fBstrptime()\fRassumes
610 0 as the year offset, then calculates the year, and assigns \fBtm_year\fR.
613 The following describes extended features when \fB_STRPTIME_DONTZERO\fR is
619 If \fB%C\fR is specified and \fB%y\fR is not specified, \fBstrptime()\fR
620 assumes the year offset of the year value of the \fBtm_year\fR member of the
621 input \fBtm struct\fR, then calculates the year and assigns \fBtm_year\fR.
627 If \fB%j\fR is specified and neither \fB%y\fR, \fB%Y\fR, nor \fB%C\fR are
628 specified, and neither month nor day of month are specified, \fBstrptime()\fR
629 assumes the year value given by the value of the \fBtm_year\fR field of the
630 input \fBtm struct\fR. Then, in addition to setting \fBtm_yday\fR,
631 \fBstrptime()\fR uses day-of-year and year values to calculate the month and
632 day-of-month, and assigns \fBtm_month\fR and \fBtm_mday\fR.
638 If \fB%U\fR or \fB%W\fR is specified, and if weekday and/or year are not given,
639 and month and day of month are not given, \fBstrptime()\fR will assume the
640 weekday value and/or the year value as the value of the \fBtm_wday\fR field
641 and/or \fBtm_year\fR field of the input \fBtm struct\fR. Then,
642 \fBstrptime()\fR will calculate the month and day-of-month and assign
643 \fBtm_month\fR, \fBtm_mday\fR, and/or \fBtm_year\fR.
649 If \fB%p\fR is specified and if hour is not specified, \fBstrptime()\fR will
650 reference, and if needed, update the \fBtm_hour\fR member. If the \fBam_pm\fR
651 input is p.m. and the input \fBtm_hour\fR value is between 0 - 11,
652 \fBstrptime()\fR will add 12 hours and update \fBtm_hour\fR. If the
653 \fBam_pm\fR input is a.m. and input \fBtm_hour\fR value is between 12 - 23,
654 \fBstrptime()\fR will subtract 12 hours and update \fBtm_hour\fR.
658 Upon successful completion, \fBstrptime()\fR returns a pointer to the character
659 following the last character parsed. Otherwise, a null pointer is returned.
662 Several "same as" formats, and the special processing of white-space characters
663 are provided in order to ease the use of identical \fIformat\fR strings for
664 \fBstrftime\fR(3C) and \fBstrptime()\fR.
666 The \fBstrptime()\fR function tries to calculate \fBtm_year\fR, \fBtm_mon\fR,
667 and \fBtm_mday\fR when given incomplete input. This allows the \fBstruct tm\fR
668 created by \fBstrptime()\fR to be passed to \fBmktime\fR(3C) to produce a
669 \fBtime_t\fR value for dates and times that are representable by a
670 \fBtime_t\fR. As an example, since \fBmktime()\fR ignores \fBtm_yday\fR,
671 \fBstrptime()\fR calculates \fBtm_mon\fR and \fBtm_mday\fR as well as filling
672 in \fBtm_yday\fR when \fB%j\fR is specified without otherwise specifying a
673 month and day within month.
676 See \fBattributes\fR(5) for descriptions of the following attributes:
681 ATTRIBUTE TYPE ATTRIBUTE VALUE
685 Interface Stability See below.
689 Standard See \fBstandards\fR(5) for \fBstrptime()\fR.
693 The \fBstrptime()\fR function is Standard. The \fBstrptime_l()\fR function
697 \fBctime\fR(3C), \fBgetdate\fR(3C), \fBisspace\fR(3C), \fBmktime\fR(3C),
699 \fBsetlocale\fR(3C), \fBstrftime\fR(3C), \fBuselocale\fR(3C),
700 \fBattributes\fR(5), \fBenviron\fR(5),