Rebase for tzdata 2016f
[platform/upstream/tzdata.git] / newstrftime.3.txt
1 NEWSTRFTIME(3)                                                  NEWSTRFTIME(3)
2
3 NAME
4        strftime - format date and time
5
6 SYNOPSIS
7        #include <sys/types.h>
8        #include <time.h>
9
10        size_t strftime(buf, maxsize, format, timeptr)
11        char *buf;
12        size_t maxsize;
13        const char *format;
14        const struct tm *timeptr
15
16        cc ... -ltz
17
18 DESCRIPTION
19        The strftime function formats the information from timeptr into the
20        buffer buf according to the string pointed to by format.
21
22        The format string consists of zero or more conversion specifications
23        and ordinary characters.  All ordinary characters are copied directly
24        into the buffer.  A conversion specification consists of a percent sign
25        and one other character.
26
27        No more than maxsize characters are be placed into the array.  If the
28        total number of resulting characters, including the terminating null
29        character, is not more than maxsize, strftime returns the number of
30        characters in the array, not counting the terminating null.  Otherwise,
31        zero is returned.
32
33        Each conversion specification is replaced by the characters as follows
34        which are then copied into the buffer.
35
36        %A     is replaced by the locale's full weekday name.
37
38        %a     is replaced by the locale's abbreviated weekday name.
39
40        %B     is replaced by the locale's full month name.
41
42        %b or %h
43               is replaced by the locale's abbreviated month name.
44
45        %C     is replaced by the century (a year divided by 100 and truncated
46               to an integer) as a decimal number (00-99).
47
48        %c     is replaced by the locale's appropriate date and time
49               representation.
50
51        %D     is replaced by the date in the format %m/%d/%y.
52
53        %d     is replaced by the day of the month as a decimal number (01-31).
54
55        %e     is replaced by the day of month as a decimal number (1-31);
56               single digits are preceded by a blank.
57
58        %F     is replaced by the date in the format %Y-%m-%d.
59
60        %G     is replaced by the ISO 8601 year with century as a decimal
61               number.
62
63        %g     is replaced by the ISO 8601 year without century as a decimal
64               number (00-99).
65
66        %H     is replaced by the hour (24-hour clock) as a decimal number
67               (00-23).
68
69        %I     is replaced by the hour (12-hour clock) as a decimal number
70               (01-12).
71
72        %j     is replaced by the day of the year as a decimal number
73               (001-366).
74
75        %k     is replaced by the hour (24-hour clock) as a decimal number
76               (0-23); single digits are preceded by a blank.
77
78        %l     is replaced by the hour (12-hour clock) as a decimal number
79               (1-12); single digits are preceded by a blank.
80
81        %M     is replaced by the minute as a decimal number (00-59).
82
83        %m     is replaced by the month as a decimal number (01-12).
84
85        %n     is replaced by a newline.
86
87        %p     is replaced by the locale's equivalent of either AM or PM.
88
89        %R     is replaced by the time in the format %H:%M.
90
91        %r     is replaced by the locale's representation of 12-hour clock time
92               using AM/PM notation.
93
94        %S     is replaced by the second as a decimal number (00-60).
95
96        %s     is replaced by the number of seconds since the Epoch, UTC (see
97               mktime(3)).
98
99        %T     is replaced by the time in the format %H:%M:%S.
100
101        %t     is replaced by a tab.
102
103        %U     is replaced by the week number of the year (Sunday as the first
104               day of the week) as a decimal number (00-53).
105
106        %u     is replaced by the weekday (Monday as the first day of the week)
107               as a decimal number (1-7).
108
109        %V     is replaced by the week number of the year (Monday as the first
110               day of the week) as a decimal number (01-53).  If the week
111               containing January 1 has four or more days in the new year, then
112               it is week 1; otherwise it is week 53 of the previous year, and
113               the next week is week 1.
114
115        %W     is replaced by the week number of the year (Monday as the first
116               day of the week) as a decimal number (00-53).
117
118        %w     is replaced by the weekday (Sunday as the first day of the week)
119               as a decimal number (0-6).
120
121        %X     is replaced by the locale's appropriate time representation.
122
123        %x     is replaced by the locale's appropriate date representation.
124
125        %Y     is replaced by the year with century as a decimal number.
126
127        %y     is replaced by the year without century as a decimal number
128               (00-99).
129
130        %Z     is replaced by the time zone name, or by the empty string if
131               this is not determinable.
132
133        %z     is replaced by the offset from UTC in the format +HHMM or -HHMM
134               as appropriate, with positive values representing locations east
135               of Greenwich, or by the empty string if this is not
136               determinable.
137
138        %%     is replaced by a single %.
139
140        %+     is replaced by the date and time in date(1) format.
141
142 SEE ALSO
143        date(1), getenv(3), newctime(3), newtzset(3), time(2), tzfile(5)
144
145                                                                 NEWSTRFTIME(3)