Print this page
2964 need POSIX 2008 locale object support
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
Approved by: TBD

Split Close
Expand all
Collapse all
          --- old/usr/src/man/man3c/strftime.3c
          +++ new/usr/src/man/man3c/strftime.3c
   1    1  '\" te
        2 +.\" Copyright 2014 Garrett D'Amore <garrett@damore.org>
   2    3  .\" Copyright (c) 2014 Gary Mills
   3    4  .\" Copyright (c) 2008, Sun Microsystems, Inc.  All Rights Reserved.
   4    5  .\" Copyright 1989 AT&T
   5    6  .\" Portions Copyright (c) 1992, X/Open Company Limited.  All Rights Reserved.
   6    7  .\" 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
   7    8  .\" http://www.opengroup.org/bookstore/.
   8    9  .\" 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.
   9   10  .\"  This notice shall appear on any product containing this material.
  10   11  .\" 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.
  11   12  .\" 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.
  12   13  .\" 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]
  13      -.TH STRFTIME 3C "Jan 3, 2014"
       14 +.TH STRFTIME 3C "Jun 24, 2014"
  14   15  .SH NAME
  15      -strftime, cftime, ascftime \- convert date and time to string
       16 +strftime, strftime_l cftime, ascftime \- convert date and time to string
  16   17  .SH SYNOPSIS
  17   18  .LP
  18   19  .nf
  19   20  #include <time.h>
  20   21  
  21   22  \fBsize_t\fR \fBstrftime\fR(\fBchar *restrict\fR \fIs\fR, \fBsize_t\fR \fImaxsize\fR,
  22   23       \fBconst char *restrict\fR \fIformat\fR,
  23   24       \fBconst struct tm *restrict\fR \fItimeptr\fR);
  24   25  .fi
  25      -
  26   26  .LP
  27   27  .nf
       28 +\fBsize_t\fR \fBstrftime_l\fR(\fBchar *restrict\fR \fIs\fR, \fBsize_t\fR \fImaxsize\fR,
       29 +     \fBconst char *restrict\fR \fIformat\fR,
       30 +     \fBconst struct tm *restrict\fR \fItimeptr\fR, \fBlocale_t\fR \fIloc\fR);
       31 +.fi
       32 +.LP
       33 +.nf
  28   34  \fBint\fR \fBcftime\fR(\fBchar *\fR\fIs\fR, \fBchar *\fR\fIformat\fR, \fBconst time_t *\fR\fIclock\fR);
  29   35  .fi
  30      -
  31   36  .LP
  32   37  .nf
  33   38  \fBint\fR \fBascftime\fR(\fBchar *\fR\fIs\fR, \fBconst char *\fR\fIformat\fR,
  34   39       \fBconst struct tm *\fR\fItimeptr\fR);
  35   40  .fi
  36   41  
  37   42  .SH DESCRIPTION
  38   43  .sp
  39   44  .LP
  40      -The \fBstrftime()\fR, \fBascftime()\fR, and \fBcftime()\fR functions place
       45 +The \fBstrftime()\fR, \fBstrftime_l()\fR, \fBascftime()\fR, and \fBcftime()\fR
       46 +functions place
  41   47  bytes into the array pointed to by \fIs\fR as controlled by the string pointed
  42   48  to by \fIformat\fR. The \fIformat\fR string consists of zero or more conversion
  43   49  specifications and ordinary characters.  A conversion specification consists of
  44   50  a '\fB%\fR' (percent) character and one or two terminating conversion
  45   51  characters that determine the conversion specification's behavior.  All
  46   52  ordinary characters (including the terminating null byte) are copied unchanged
  47   53  into the array pointed to by \fIs\fR. If copying takes place between objects
  48   54  that overlap, the behavior is undefined. For \fBstrftime()\fR, no more than
  49      -\fImaxsize\fR bytes are placed into the array.
  50      -.sp
       55 +\fImaxsize\fR bytes are placed into the array. The \fBstrftime_l()\fR function
       56 +behaves identically to \fBstrftime()\fR function, but instead of operating in
       57 +the current locale, it operates in the locale specified by \fIloc\fR.
  51   58  .LP
  52   59  If \fIformat\fR is \fB(char *)0\fR, then the locale's default format is used.
  53   60  For \fBstrftime()\fR the default format is the same as \fB%c\fR; for
  54   61  \fBcftime()\fR and \fBascftime()\fR the default format is the same as \fB%+\fR.
  55   62  \fBcftime()\fR and \fBascftime()\fR first try to use the value of the
  56   63  environment variable \fBCFTIME\fR, and if that is undefined or empty, the
  57   64  default format is used.
  58      -.sp
  59   65  .LP
  60   66  Each conversion specification is replaced by appropriate characters as
  61   67  described in the following list. The appropriate characters are determined by
  62   68  the \fBLC_TIME\fR category of the program's locale and by the values contained
  63   69  in the structure pointed to by \fItimeptr\fR for \fBstrftime()\fR and
  64   70  \fBascftime()\fR, and by the time represented by \fIclock\fR for
  65   71  \fBcftime()\fR.
  66   72  .sp
  67   73  .ne 2
  68   74  .na
↓ open down ↓ 389 lines elided ↑ open up ↑
 458  464  
 459  465  .sp
 460  466  .ne 2
 461  467  .na
 462  468  \fB\fB%+\fR\fR
 463  469  .ad
 464  470  .RS 6n
 465  471  Locale's date and time representation as produced by \fBdate\fR(1).
 466  472  .RE
 467  473  
 468      -.sp
 469  474  .LP
 470  475  If a conversion specification does not correspond to any of the above or to any
 471  476  of the modified conversion specifications listed below, the behavior is
 472  477  undefined and \fB0\fR is returned.
 473      -.sp
 474  478  .LP
 475  479  The difference between \fB%U\fR and \fB%W\fR (and also between modified
 476  480  conversion specifications \fB%OU\fR and \fB%OW\fR) lies in which day is counted
 477  481  as the first of the week. Week number 1 is the first week in January starting
 478  482  with a Sunday for \fB%U\fR or a Monday for \fB%W\fR. Week number 0 contains
 479  483  those days before the first Sunday or Monday in January for \fB%U\fR and
 480  484  \fB%W\fR, respectively.
 481  485  .SS "Modified Conversion Specifications"
 482      -.sp
 483  486  .LP
 484  487  Some conversion specifications can be modified by the \fBE\fR and \fBO\fR
 485  488  modifiers to indicate that an alternate format or specification should be used
 486  489  rather than the one normally used by the unmodified conversion specification.
 487  490  If the alternate format or specification does not exist in the current locale,
 488  491  the behavior will be as if the unmodified specification were used.
 489  492  .sp
 490  493  .ne 2
 491  494  .na
 492  495  \fB\fB%Ec\fR\fR
↓ open down ↓ 181 lines elided ↑ open up ↑
 674  677  .ne 2
 675  678  .na
 676  679  \fB\fB%Oy\fR\fR
 677  680  .ad
 678  681  .RS 7n
 679  682  Year (offset from \fB%C\fR) in the locale's alternate representation and using
 680  683  the locale's alternate numeric symbols.
 681  684  .RE
 682  685  
 683  686  .SS "Selecting the Output Language"
 684      -.sp
 685  687  .LP
 686      -By default, the output of \fBstrftime()\fR, \fBcftime()\fR, and
 687      -\fBascftime()\fR appear in U.S. English. The user can request that the output
 688      -of \fBstrftime()\fR, \fBcftime()\fR, or \fBascftime()\fR be in a specific
 689      -language by setting the \fBLC_TIME\fR category using \fBsetlocale()\fR.
      688 +These routines produce output that is formatted according to the \fBLC_TIME\fR
      689 +locale category.  They use either the current locale, or in the case of
      690 +\fBstrftime_l()\fR, the locale supplied by \fIloc\fR.
 690  691  .SS "Time Zone"
 691      -.sp
 692  692  .LP
 693  693  Local time zone information is used as though \fBtzset\fR(3C) were called.
 694  694  .SH RETURN VALUES
 695      -.sp
 696  695  .LP
 697      -The \fBstrftime()\fR, \fBcftime()\fR, and \fBascftime()\fR functions return the
      696 +These functions return the
 698  697  number of characters placed into the array pointed to by \fIs\fR, not including
 699  698  the terminating null character. If the total number of resulting characters
 700  699  including the terminating null character is more than \fImaxsize\fR,
 701  700  \fBstrftime()\fR returns \fB0\fR and the contents of the array are
 702  701  indeterminate.
 703  702  .SH EXAMPLES
 704  703  .LP
 705  704  \fBExample 1 \fRAn example of the \fBstrftime()\fR function.
 706      -.sp
 707  705  .LP
 708  706  The following example illustrates the use of \fBstrftime()\fR for the
 709  707  \fBPOSIX\fR locale. It shows what the string in \fIstr\fR would look like if
 710  708  the structure pointed to by \fItmptr\fR contains the values corresponding to
 711  709  Thursday, August 28, 1986 at 12:44:36.
 712      -
 713      -.sp
 714      -.in +2
 715  710  .nf
 716      -\fBstrftime (str, strsize, "%A %b %d %j", tmptr)\fR
      711 +.IP
      712 +\fBstrftime\fR(\fIstr\fR, \fIstrsize\fR, "%A %b %d %j", \fItmptr\fR);
 717  713  .fi
 718      -.in -2
 719      -
 720      -.sp
 721  714  .LP
 722  715  This results in \fIstr\fR containing "Thursday Aug 28 240".
 723      -
 724  716  .SH ATTRIBUTES
 725      -.sp
 726  717  .LP
 727  718  See \fBattributes\fR(5) for descriptions of the following attributes:
 728      -.sp
 729      -
 730      -.sp
 731  719  .TS
 732  720  box;
 733  721  c | c
 734  722  l | l .
 735  723  ATTRIBUTE TYPE  ATTRIBUTE VALUE
 736  724  _
 737  725  CSI     Enabled
 738  726  _
 739      -Interface Stability     Committed
      727 +Interface Stability     See below.
 740  728  _
 741  729  MT-Level        MT-Safe
 742  730  _
 743  731  Standard        See below.
 744  732  .TE
 745  733  
 746      -.sp
 747  734  .LP
 748      -For \fBstrftime()\fR, see \fBstandards\fR(5).
      735 +The \fBstrftime()\fR and \fBstrftime_l()\fR functions are Standard.
      736 +\fBcftime()\fR and \fBascftime()\fR functions are Committed.
      737 +.LP
      738 +For \fBstrftime()\fR and \fBstrftime_l()\fR, see \fBstandards\fR(5).
 749  739  .SH SEE ALSO
 750      -.sp
 751  740  .LP
 752      -\fBdate\fR(1), \fBctime\fR(3C), \fBmktime\fR(3C), \fBsetlocale\fR(3C),
 753      -\fBstrptime\fR(3C), \fBtzset\fR(3C), \fBTIMEZONE\fR(4), \fBzoneinfo\fR(4),
      741 +\fBdate\fR(1), \fBctime\fR(3C), \fBmktime\fR(3C),
      742 +\fBnewlocale\fR(3C), \fBsetlocale\fR(3C), \fBstrptime\fR(3C), \fBtzset\fR(3C),
      743 +\fBuselocale\fR(3C), \fBTIMEZONE\fR(4), \fBzoneinfo\fR(4),
 754  744  \fBattributes\fR(5), \fBenviron\fR(5), \fBstandards\fR(5)
 755  745  .SH NOTES
 756      -.sp
 757  746  .LP
 758  747  The conversion specification for \fB%V\fR was changed in the Solaris 7 release.
 759  748  This change was based on the public review draft of the ISO C9x standard at
 760  749  that time. Previously, the specification stated that if the week containing 1
 761  750  January had fewer than four days in the new year, it became week 53 of the
 762  751  previous year. The ISO C9x standard committee subsequently recognized that that
 763  752  specification had been incorrect.
 764      -.sp
 765  753  .LP
 766  754  The conversion specifications for \fB%g\fR, \fB%G\fR, \fB%Eg\fR, \fB%EG\fR, and
 767  755  \fB%Og\fR were added in the Solaris 7 release.  This change was based on the
 768      -public review draft of the ISO C9x standard at that time. These specifications
 769      -are evolving.  If the ISO C9x standard is finalized with a different
 770      -conclusion, these specifications will change to conform to the ISO C9x standard
 771      -decision.
 772      -.sp
      756 +public review draft of the ISO C9x standard at that time. The \fB%g\fR and
      757 +\fB%G\fR specifications were adopted in the formal standard.  The other two
      758 +were not, and should not be used in portable applications.
 773  759  .LP
 774  760  The conversion specification for \fB%u\fR was changed in the Solaris 8 release.
 775  761  This change was based on the XPG4 specification.
 776      -.sp
 777  762  .LP
 778  763  If using the \fB%Z\fR specifier and \fBzoneinfo\fR timezones and if the input
 779  764  date is outside the range 20:45:52 UTC, December  13, 1901 to 03:14:07 UTC,
 780  765  January 19, 2038, the timezone name may not be correct.
 781      -.sp
 782  766  .LP
 783  767  The conversion specification for \fB%+\fR was added in illumos.
 784  768  It is not part of any standard, although it is available on a number
 785  769  of other platforms.
 786  770  Its use is discouraged for conforming applications.
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX