strptime(3c) 맨 페이지 - 윈디하나의 솔라나라

개요

섹션
맨 페이지 이름
검색(S)

strptime(3c)

strptime(3C)             Standard C Library Functions             strptime(3C)

NAME
       strptime - date and time conversion

SYNOPSIS
       #include <time.h>

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

   Non-zeroing Behavior
       cc [flag...]  file... -D_STRPTIME_DONTZERO [library...]
       #include <time.h>

       char *strptime(const char *restrict buf,
            const char *restrict format, struct tm *restrict 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.


       The format argument is composed of zero or more  conversion  specifica‐
       tions.  Each  conversion  specification  is composed of a "%" (percent)
       character followed by one or two conversion  characters  which  specify
       the replacement required. One or more white space characters (as speci‐
       fied  by isspace(3C)) may precede or follow a conversion specification.
       There must be white-space or other non-alphanumeric characters  between
       any two conversion specifications.


       A  non-zeroing version of strptime(), described below under Non-zeroing
       Behavior, is provided if _STRPTIME_DONTZERO is defined.


       In SUSv4 conforming application, the following can appear  in  sequence
       in  each  conversion  specification,  between % (percent) character and
       conversion character. The results are  unspecified  if  a  modifier  is
       specified  with  a  flag  or  with a minimum field width, or if a field
       width is specified for any conversion specifier other than C or Y.

           o      An optional flag, the zero character ('0') or the  plus-sign
                  character ('+'), which is ignored.


           o      An  optional  field width. If a field width is specified, it
                  is interpreted as a string of decimal digits that  will  de‐
                  termine  the  maximum number of bytes converted for the con‐
                  version rather than the number of bytes specified  below  in
                  the description of the conversion specifiers.


   Conversion Specifications
       The following conversion specifications are supported:

       %    Same as %.


       a    Day of week, using the locale's weekday names; either the abbrevi‐
            ated or full name may be specified.


       A    Same as %a.


       b    Month,  using  the locale's month names; either the abbreviated or
            full name may be specified.


       B    Same as %b.


       c    Locale's appropriate date and time representation.


       C
            SUSv4

                For SUSv4, all but the last two digits of the  year.  At  most
                two  bytes  are  scanned,  unless  the optional field width is
                specified. Leading zeros are permitted but are not required. A
                leading '+' or '-' character is permitted before  any  leading
                zeros but is not required.


            Default and other standards

                For  default and other standards, century number (the year di‐
                vided by 100 and truncated to an integer as a  decimal  number
                [1,99]);  single digits are preceded by 0. If %C is used with‐
                out the %y specifier, strptime() assumes the  year  offset  is
                zero  in  whichever century is specified. Note the behavior of
                %C in the absence of %y is not specified by any of  the  stan‐
                dards  or  specifications described on the standards(7) manual
                page, so portable applications should not depend on  it.  This
                behavior may change in a future release.



       d    Day of month [1,31]; leading zero is permitted but not required.


       D    Date as %m/%d/%y.


       e    Same as %d.


       F    Equivalent  to  %Y-%m-%d  (the  ISO 8601:2004 standard date in ex‐
            tended format).


       g    Week-based year within century [00,99]; leading zero is  permitted
            but not required.


       G    Week-based  year,  including the century [0000,9999]; leading zero
            is permitted but not required.


       h    Same as %b.


       H    Hour (24-hour clock) [0,23]; leading zero is permitted but not re‐
            quired.


       I    Hour (12-hour clock) [1,12]; leading zero is permitted but not re‐
            quired.


       j    Day number of the year [1,366]; leading zeros  are  permitted  but
            not required.


       k    Same as %H.


       l    Same as %I.


       m    Month number [1,12]; leading zero is permitted but not required.


       M    Minute [0-59]; leading zero is permitted but not required.


       n    Any white space.


       p    Locale's equivalent of either a.m. or p.m.


       P    Locale's  equivalent  of  either  a.m. or p.m. in case-insensitive
            manner.


       r    Appropriate time representation in the 12-hour clock  format  with
            %p.


       R    Time as %H:%M.


       S
            SUSv3

                Seconds  [0,60];  leading  zero is permitted but not required.
                The range of values is [00,60] rather than  [00,59]  to  allow
                for the occasional leap second.


            Default and other standards

                Seconds  [0,61];  leading  zero is permitted but not required.
                The range of values is [00,61] rather than  [00,59]  to  allow
                for the occasional leap second and even more occasional double
                leap second.



       t    Any white space.


       T    Time as %H:%M:%S.


       u    Weekday as a decimal number [1,7], with 1 representing Monday.


       U    Week number of the year as a decimal number [0,53], with Sunday as
            the  first  day of the week; leading zero is permitted but not re‐
            quired.


       V    The ISO 8601 week number as a decimal number [01,53]. In  the  ISO
            8601  week-based system, weeks begin on a Monday and week 1 of the
            year is the week that includes both  January  4th  and  the  first
            Thursday  of  the year. If the first Monday of January is the 2nd,
            3rd, or 4th, the preceding days are part of the last week  of  the
            preceding year.


       w    Weekday as a decimal number [0,6], with 0 representing Sunday.


       W    Week number of the year as a decimal number [0,53], with Monday as
            the  first  day of the week; leading zero is permitted but not re‐
            quired.


       x    Locale's appropriate date representation.


       X    Locale's appropriate time representation.


       y
            SUSv4

                The last two digits of the year. When format contains  neither
                a  C conversion specifier nor a Y conversion specifier, values
                in the range [69,99] refer to years 1969 to 1999 inclusive and
                values in the range [00,68] refer to years 2000 to 2068 inclu‐
                sive. Leading zeros are permitted  but  are  not  required.  A
                leading  '+'  or '-' character is permitted before any leading
                zeros but are not required.

                It is expected that in a future release  the  default  century
                inferred from a 2-digit year will change.


            Default and other standards

                Year  within  century.  When a century is not otherwise speci‐
                fied, values in the range 69-99 refer to years in the  twenti‐
                eth  century  (1969  to  1999  inclusive); values in the range
                00-68 refer to years in the twenty-first century (2000 to 2068
                inclusive).



       Y
            SUSv4

                The full year. At most four bytes are scanned, unless the  op‐
                tional  field  width is specified. Leading zeros are permitted
                but are not required. A leading '+' or '-' character  is  per‐
                mitted but are not required.


            Default and other standards

                Year, including the century (for example, 1993).



       z    Offset  from  UTC in ISO 8601:2004 standard basic format (+hhmm or
            -hhmm), or no characters if no time zone is determinable.


       Z    Time zone name or no characters if no time zone exists.


   Modified Conversion Specifiers
       Some conversion specifications can be modified by the E and O  modifier
       characters to indicate that an alternate format or specification should
       be  used rather than the one normally used by the unmodified specifica‐
       tion. If the alternate format or specification does not  exist  in  the
       current  locale,  the  behavior will be as if the unmodified conversion
       specification were used.

       %Ec    Locale's alternate appropriate date and time representation.


       %EC    Name of the base year (era) in the locale's alternate  represen‐
              tation.


       %Ex    Locale's alternate date representation.


       %EX    Locale's alternate time representation.


       %Ey    Offset  from %EC (year only) in the locale's alternate represen‐
              tation.


       %EY    Full alternate year representation.


       %Od    Day of the month using the locale's alternate numeric symbols.


       %Oe    Same as %Od.


       %OH    Hour (24-hour clock) using the locale's alternate  numeric  sym‐
              bols.


       %OI    Hour  (12-hour  clock) using the locale's alternate numeric sym‐
              bols.


       %Om    Month using the locale's alternate numeric symbols.


       %OM    Minutes using the locale's alternate numeric symbols.


       %OS    Seconds using the locale's alternate numeric symbols.


       %OU    Week number of the year (Sunday as the first day  of  the  week)
              using the locale's alternate numeric symbols.


       %Ow    Number  of  the  weekday (Sunday=0) using the locale's alternate
              numeric symbols.


       %OW    Week number of the year (Monday as the first day  of  the  week)
              using the locale's alternate numeric symbols.


       %Oy    Year  (offset  from %C) in the locale's alternate representation
              and using the locale's alternate numeric symbols.


   General Specifications
       A conversion specification 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 specification, the
       specification fails, and the differing and subsequent characters remain
       unscanned.


       A series of specifications 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
       characters can be scanned. White space is defined by isspace(3C).


       Any  other  conversion specification is executed by scanning characters
       until a character matching the next specification is scanned, or  until
       no  more  characters  can  be scanned. These characters, except the one
       matching the next specification, are then compared to the locale values
       associated with the conversion specifier. If a match is  found,  values
       for  the appropriate tm structure members are set to values correspond‐
       ing to the locale information. If no match is found,  strptime()  fails
       and no more characters are scanned.


       The  month  names, weekday names, era names, and alternate numeric sym‐
       bols can consist of any combination of upper and lowercase letters. The
       user can request that the input date or time specification be in a spe‐
       cific language by setting the LC_TIME category using setlocale(3C).

   Non-zeroing Behavior
       In addition to the behavior described above by various  standards,  the
       Solaris implementation of strptime() provides the following extensions.
       These  may  change  at  any  time  in the future. Portable applications
       should not depend on these extended features:

           o      If _STRPTIME_DONTZERO is not defined, the tm struct  is  ze‐
                  roed  on  entry  and strptime() updates the fields of the tm
                  struct associated with the specifiers in the format string.


           o      If _STRPTIME_DONTZERO is defined, strptime() does  not  zero
                  the  tm  struct on entry. Additionally, for some specifiers,
                  strptime() will use some values in the input  tm  struct  to
                  recalculate  the  date and re-assign the appropriate members
                  of the tm struct.



       The following describes extended features regardless of whether  _STRP‐
       TIME_DONTZERO is defined or not defined:

           o      If %j is specified, tm_yday is set; if year is given, and if
                  month  and day are not given, strptime() calculates and sets
                  tm_mon, tm_mday, and tm_year.


           o      If %U, %V, or %W is specified and if weekday  and  year  are
                  given  and  month and day of month are not given, strptime()
                  calculates and sets tm_mon, tm_mday, tm_wday, and tm_year.



       The following describes extended features  when  _STRPTIME_DONTZERO  is
       not defined:

           o      If %C is specified and neither %g nor %y is specified, strp‐
                  time()  assumes  0  as  the year offset, then calculates the
                  year and assigns tm_year.



       The following describes extended features  when  _STRPTIME_DONTZERO  is
       defined:

           o      If %C is specified and neither %g nor %y is specified, strp‐
                  time()  assumes  the  year  offset  of the year value of the
                  tm_year member of the input tm struct, then  calculates  the
                  year and assigns tm_year.


           o      If  %j  is  specified  and neither %C, %g, %G, %y, nor %Y is
                  specified, and neither month nor day of month is  specified,
                  strptime()  assumes the year value given by the value of the
                  tm_year field of the input tm struct. Then, in  addition  to
                  setting tm_yday, strptime() uses day-of-year and year values
                  to   calculate  the  month  and  day-of-month,  and  assigns
                  tm_month and tm_mday.


           o      If %U, %V, or %W is specified, and if  weekday  and/or  year
                  are  not  given,  and  month and day of month are not given,
                  strptime() will assume the weekday  value  and/or  the  year
                  value as the value of the tm_wday field and/or tm_year field
                  of  the input tm struct. Then, strptime() will calculate the
                  month and day-of-month and assign tm_month, tm_mday,  and/or
                  tm_year.


           o      If %p or %P is specified and if hour is not specified, strp‐
                  time()  will  reference,  and  if needed, update the tm_hour
                  member. If the am_pm input is p.m.  and  the  input  tm_hour
                  value  is  between  0 - 11, strptime() will add 12 hours and
                  update tm_hour. If the am_pm input is a.m. and input tm_hour
                  value is between 12 - 23, strptime() will subtract 12  hours
                  and update tm_hour.


RETURN VALUES
       Upon successful completion, strptime() returns a pointer to the charac‐
       ter  following  the last character parsed. Otherwise, a null pointer is
       returned.

USAGE
       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(3C) and strptime().


       The strptime() function tries to calculate tm_year, tm_mon, and tm_mday
       when given incomplete input. This allows the struct tm created by strp‐
       time() to be passed to mktime(3C) to produce a time_t value  for  dates
       and  times that are representable by a time_t. As an example, since mk‐
       time() ignores tm_yday, strptime() calculates  tm_mon  and  tm_mday  as
       well as filling in tm_yday when %j is specified without otherwise spec‐
       ifying a month and day within month.

ATTRIBUTES
       See attributes(7) for descriptions of the following attributes:

       tab()  box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) ATTRIBUTE TYPEAT‐
       TRIBUTE VALUE _ CSIEnabled _ Interface StabilityCommitted _ MT-LevelMT-
       Safe _ StandardSee standards(7).


SEE ALSO
       ctime(3C), duplocale(3C), freelocale(3C), getdate(3C), isspace(3C), mk‐
       time(3C), newlocale(3C),  setlocale(3C),  strftime(3C),  uselocale(3C),
       attributes(7), environ(7), standards(7)


       Managing  System  Locales in Internationalizing and Localizing Applica‐
       tions in Oracle Solaris

HISTORY
       The strptime() function has been included in all  Sun  and  Oracle  re‐
       leases of Solaris.

Oracle Solaris 11.4               25 Nov 2024                     strptime(3C)
맨 페이지 내용의 저작권은 맨 페이지 작성자에게 있습니다.
RSS ATOM XHTML 5 CSS3