aboutsummaryrefslogtreecommitdiffstats
path: root/doc/info/chap/strftime.texinfo
blob: 49fa22440cd563576aa76acc4d941458834f8e22 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
@node strftime
@chapter @code{strftime}

@command{scrotty} uses @code{strftime}, which
implemented by the @sc{C} standard library (the
@sc{GNU} @sc{C} Library for most @sc{GNU}/Linux
user,) for formatting the filename or commands
with information about the current date and time.
If you are using the @sc{GNU} @sc{C} Library,
full documentation is available in
@ref{Formatting Calendar Time, Formatting Calendar Time, Formatting Calendar Time, libc, GNU C Library Application Fundamentals}.

Assuming your have a @sc{POSIX}-compliant
implementation of @code{strftime}, at least the
following formatters are supported:

@table @code
@item %a
The name of weekday in your locale, abbreviated.
For example `Tue'.
@item %A
The name of weekday in your locale. For example
`Tuesday'.
@item %b
@itemx %h
The name of month in your locale, abbreviated.
For example `Dec'.
@item %B
The name of month in your locale. For example
`December.
@item %c
Your locale's representation for the date and
time. For example `Tue 08 Dec 2015 09:40:34 CET'.
@item %C
The ``century'', or more precisely the year
divided by 100 and trucated to an integer.
Between year 2000 and 2099, inclusively, this
will be `20'.
@item %d
The day of the month in two digits. For example,
`08' during 8 of December.
@item %D
Equivalent to @code{%m/%d/%y}. For example
@code{12/08/15} for 8 of December 2015.

Be aware, this not what expect in most of the
World, and its requires specialised sorting
algorithms to be sorted properly. Be also
aware, that this contains forward slashes, which
is used as the file delimiter. This is a poor
idea to use this for the filename. @code{%F}
is a better choice.
@item %e
The day of the month. If only one digit is
required, it is preceded by a space. For
example, ` 8' during 8 of December.
@item %F
Equivalent to @code{%+4Y-%m-%d}. For example
@code{2015-12-08} for 8 of December 2015.
@item %g
The last 2 digits of the week-based year.
@item %G
The week-based year.
@item %H
The hour in 24-hour clock format, 2 digits.
@item %-H
The hour in 24-hour clock format, as few digits as possible.
@item %I
The hour in 12-hour clock format, 2 digits.
@item %-I
The hour in 12-hour clock format, as few digits as possible.
@item %j
The day of the year in 3 digits.
For example @code{342} for 8 of December 2015.
@item %-j
The day of the year in as few digits as possible.
@item %m
The month in 2 digits.
For example @code{12} for 8 of December 2015.
@item %-m
The month in as few digits as possible.
@item %M
The minute in 2 digits.
@item %n
A new line.
@item %p
The locale's repesentation for either ante
meridiem or post meridiem.
@item %r
The time in 12-hour notation. The behaviour
is not completely specified. You will have
to try it out. It will probably include
the second and the timezone.
@item %R
The time, in minute resolution, in 24-hour
notation.@footnote{Yes, this is barely similar to
@code{%r}.}
@item %S
The second, in too digits. Currently leap-seconds
are not supported, and @sc{POSIX} does not specify
that double positive leap-seconds are
possible@footnote{Probably because they are avoided.}.
@item %t
A tab space.
@item %T
Equivalent to @code{%H:%M:%S}.
@item %u
The weekday as a number, starting with Monday as 1.
@item %U
The week number of the year, 2 digits.
The first Sunday of January is the first day of
week 1. Week 0 is possible.
@item %-U
Equivalent to @code{-U}, except in as few digits
as possible.
@item %V
The week number of the year, 2 digits.
IF week containing 1 of January has at least four
days in the new year, it is week 1. Week 0 is
impossible.
@item %-V
Equivalent to @code{-V}, except in as few digits
as possible.
@item %w
The weekday as a number, starting with Sunday as 0.
@item %W
The week number of the year, 2 digits.
The first Monday of January is the first day of
week 1. Week 0 is possible.
@item %-W
Equivalent to @code{-W}, except in as few digits
as possible.
@item %x
The locale's representation of the date. This
may be equivalent or similar to @code{%F} and
thus a poor idea to use, if so.
@item %X
The locale's representation of the time.
@item %y
The last two digits in the year. (And at least two digits.)
@item %Y
The year with as many digits as necessary.
@item %z
The offset of the timezone from UTC. Either
@code{+hhmm} or @code{-hhmm} (starts with a hyphen.)
@item %Z
The name of the timezone, abbreviation.
@item %%
A literal `%'.
@end table

Note, this is not all that @sc{POSIX} specifies,
but it is the basics. @sc{POSIX} does not specify
any support for 6-hour clocks, for Saturday as the
first day of the week (or Tuesay through Friday,) or
Sunday to be represented by 1 or Monday as 0. If you
need any of these, you should look into the
specifications for your @sc{C} standard libraries
implementation of @code{strftime}, which may or may
nor support this.