Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ strptime(3C) — Reliant UNIX 5.44c4

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

time(2)

strftime(3C)

scanf(3S)

time(5)

strptime(3C)                                                   strptime(3C)

NAME
     strptime - date and time conversion

SYNOPSIS
     #include <time.h>

     char *strptime(const char *buf, const char *format, struct tm *tm);

DESCRIPTION
     The strptime() function converts the character string pointed to by
     buf to values which are stored in the tm structure pointed to by tm,
     using the format specified by format.

     format is composed of zero or more directives. Each directive is com-
     posed of one of the following: one or more white-space characters (as
     specified by the isspace() function); an ordinary character (neither %
     nor a white-space character); or a conversion specification. Each
     conversion specification is composed of a % character followed by a
     conversion character which specifies the replacement required. There
     must be white-space or other non-alphanumeric characters between any
     two conversion specifications. The following conversion specifications
     are supported:

     %a    Is the day of week, using the locales weekday names; either the
           abbreviated or full name may be specified.

     %A    Is the same as %a.

     %b    Is the month, using the locales month names; either the abbrevi-
           ated or full name may be specified.

     %B    Is the same as %b.

     %c    Is the date and time, using locales date and time format (for
           example, as %x%X).

     %C    Is the century number [0,99]; leading zeros are permitted but
           not required.

     %d    Is the day of the month [1,31]; leading zeros are permitted but
           not required.

     %D    Is the date as %m/%d/%y.

     %e    Is the same as %d.

     %h    Is the same as %b.

     %H    Is the hour (24-hour clock) [0,23]; leading zeros are permitted
           but not required.





Page 1                       Reliant UNIX 5.44                Printed 11/98

strptime(3C)                                                   strptime(3C)

     %I    Is the hour (12-hour clock) [1,12]; leading zeros are permitted
           but not required.

     %j    Is the day number of the year [1,366]; leading zeros are permit-
           ted but not required.

     %m    Is the month number [1,12]; leading zeros are permitted but not
           required.

     %M    Is the minute [0,59]; leading zeros are permitted but not
           required.

     %n    Any white space.

     %p    Is the locales equivalent of a.m. or p.m.

     %r    Is the time as %I:%M:%S:%p.

     %R    Is the time as %H:%M.

     %S    Is the second [0,61]; leading zeros are permitted but not
           required.

     %t    Is any white space.

     %T    Is the time as %H:%M:%S.

     %U    Is the week number of the year (Sunday as the first day of the
           week) a decimal number [00,53]; leading zeros are permitted but
           not required.

     %w    Is the weekday as a decimal number [0,6], with 0 representing
           Sunday; leading zeros are permitted but not required.

     %W    Is the week number of the year (Monday as first day of the week)
           as a decimal number [00,53]; leading zeros are permitted but not
           required.

     %x    Is the date, using the locales date format.

     %X    Is the time, using the locales time format.

     %y    Is the year within the century [0,99]; leading zeros are permit-
           ted but not required.

     %Y    Is the year including the century (for example 1988).

     %%    Is replaced by %.






Page 2                       Reliant UNIX 5.44                Printed 11/98

strptime(3C)                                                   strptime(3C)

   Modified Directives

     Some directives can be modified by the E and O modifier characters to
     indicate that an alternative format or specification should be used
     rather than the one normally used by the unmodified directive (see
     "Programmer's Guide: Internationalization - Localization"). If the
     alternative format or specification does not exist in the current
     locale, the behavior will be as if the unmodified directive were used.

     %Ec   Is the locales alternative appropriate date and and time repre-
           sentation.

     %EC   Is the name of the base year (period) in the locales alternative
           representation.

     %Ex   Is the locales alternative date representation.

     %EX   Is the locales alternative time representation.

     %Ey   Is the offset from %EC (year only) in the locales alternative
           representation.

     %EY   Is the full alternative year representation

     %Od   Is the day of the month using the locales alternative numeric
           symbols; leading zeros are permitted but not required.

     %Oe   Is the same as %Od.

     %OH   Is the hour (24-hour clock) using the locales alternative
           numeric symbols.

     %OI   Is the hour (12-hour clock) using the locales alternative
           numeric symbols.

     %Om   Is the month using the locales alternative numeric symbols.

     %OM   Is the minutes using the locales alternative numeric symbols.

     %OS   Is the seconds using the locales alternative numeric symbols.

     %OU   Is the week number of the year (Sunday as the first day of the
           week) using the locales alternative numeric symbols.

     %Ow   Is the number of the weekday (Sunday = 0) using the locales
           alternative numeric symbols.

     %OW   Is the week number of the year (Monday is the first day of the
           week) using the locales alternative numeric symbols.

     %Oy   Is the year (offset from %C) in the locales alternative repre-
           sentation and using the locales alternative numeric symbols.


Page 3                       Reliant UNIX 5.44                Printed 11/98

strptime(3C)                                                   strptime(3C)

     A directive composed of white-space characters is executed by scanning
     input up to the first character that is not white space (which remains
     unscanned), or until no more characters can be scanned.

     A directive that is an ordinary character is executed by scanning the
     next character from the buffer. If the character scanned from the
     buffer differs from the one comprising the directive, the directive
     fails, and the differing and subsequent characters remain unscanned.

     A series of directives composed of %n, %t, white-space characters or
     any combination is executed by scanning up to the first character that
     is not white space (which remains unscanned), or until no more charac-
     ters can be scanned.

     Any other conversion specification is executed by scanning characters
     until a character matching the next directive is scanned, or until no
     more characters can be scanned. These characters, except the one
     matching the next directive, are then compared to the locale values
     associated with the conversion specifier. If a match is found, values
     for appropriate tm structure members are set to values corresponding
     to the locale information. Case is ignored when matching items in buf
     such as month or weekday names. If no match is found, strptime() fails
     and no more characters can be scanned.

     Several "same as" formats, and the special processing of white-space
     characters are provided in order to ease the use of identical format
     strings for strftime() and strptime().

ERRORS
     The strptime() function will fail if:

     ENOSYS    The functionality is not supported in this implementation.

RESULT
     Upon successful completion, strptime() returns a pointer to the char-
     acter following the last character parsed. Otherwise, a null pointer
     is returned.

SEE ALSO
     time(2), strftime(3C), scanf(3S), LCTIME(4), time(5).














Page 4                       Reliant UNIX 5.44                Printed 11/98

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026