1
2JSTRFTIME(3) libjalali Manual JSTRFTIME(3)
3
4
5
7 jstrftime - format jalali date and time
8
10 #include <jtime.h>
11
12 size_t jstrftime(char *s, size_t max, const char *format,
13 const struct tm *jtm);
14
15 Link with -ljalali
16
18 The jstrftime() function formats the broken-down jalali time jtm
19 according to the format specification format and places the result in
20 the character array s of size max.
21
22 The format specification is a null-terminated string and may contain
23 special character sequences called conversion specifications, each of
24 which is introduced by a '%' character and terminated by some other
25 character known as a conversion specifier character. All other charac‐
26 ter sequences are ordinary character sequences.
27
28 The characters of ordinary character sequences (including the null
29 byte) are copied verbatim from format to s. However, the characters of
30 conversion specifications are replaced as follows:
31
32 %a The abbreviated weekday name.
33
34 %A The full weekday name.
35
36 %b The abbreviated month name.
37
38 %B The full month name.
39
40 %c The preferred date and time representation.
41
42 %C The century number (year/100) as a 2-digit integer.
43
44 %d The day of the month as a decimal number (range 01 to 31).
45
46 %D Equivalent to %Y/%m/%d.
47
48 %e Like %d The day of the month as a decimal number, but a leading
49 zero is replaced by a space. (SU)
50
51 %E The preferred date and time in Farsi. (utf8)
52
53 %F Equivalent to %Y-%m-%d (similar to the ISO 8601 date format).
54 (C99)
55
56 %h The abbreviated Farsi transliterated weekday name.
57
58 %q The full Farsi transliterated weekday name.
59
60 %g The abbreviated Farsi weekday name. (utf8)
61
62 %G The full Farsi weekday name. (utf8)
63
64 %v The abbreviated Farsi month name. (utf8)
65
66 %V The full Farsi month name. (utf8)
67
68 %H The hour as a decimal number using a 24-hour clock (range 00 to
69 23).
70
71 %I The hour as a decimal number using a 12-hour clock (range 01 to
72 12).
73
74 %j The day of the year as a decimal number (range 001 to 366).
75
76 %k The hour (24-hour clock) as a decimal number (range 0 to 23);
77 single digits are preceded by a blank. (See also %H.) (TZ)
78
79 %l The hour (12-hour clock) as a decimal number (range 1 to 12);
80 single digits are preceded by a blank. (See also %I.) (TZ)
81
82 %m The month as a decimal number (range 01 to 12).
83
84 %M The minute as a decimal number (range 00 to 59).
85
86 %n A newline character. (SU)
87
88 %O AM or PM notation for the given time in Farsi equivalent. (utf8)
89
90 %p Either "AM" or "PM" according to the given time value. Noon is
91 treated as "PM" and midnight as "AM".
92
93 %P Like %p but in lowercase: "am" or "pm"
94
95 %r The time in a.m. or p.m. notation. In the POSIX locale this is
96 equivalent to %I:%M:%S %p. (SU)
97
98 %R The time in 24-hour notation (%H:%M). (SU) For a version includ‐
99 ing the seconds, see %T below.
100
101 %s The number of seconds since the Epoch, 1970-01-01 (1348-10-11)
102 00:00:00 +0000 (UTC). (TZ)
103
104 %S The second as a decimal number (range 00 to 59).
105
106 %t A tab character. (SU)
107
108 %T The time in 24-hour notation (%H:%M:%S). (SU)
109
110 %u The day of the week as a decimal, range 1 to 7, Saturday being
111 1. See also %w. (SU)
112
113 %U The week number of the current year as a decimal number, range
114 00 to 53, starting with the first Sunday as the first day of
115 week 01.
116
117 %w The day of the week as a decimal, range 0 to 6, Saturday being
118 0. See also %u.
119
120 %W The preferred date in %Y/%m/%d format and Farsi. (utf8)
121
122 %x The preferred date representation without the time.
123
124 %X The preferred time representation without the date in Farsi.
125 (utf8)
126
127 %y The year as a decimal number without a century (range 00 to 99).
128
129 %Y The year as a decimal number including the century.
130
131 %z The +hhmm or -hhmm numeric timezone (that is, the hour and
132 minute offset from UTC). (SU)
133
134 %Z The timezone or name or abbreviation.
135
136 %% A literal '%' character.
137
138 The broken-down time structure tm is defined in <jtime.h>. See also
139 jctime(3).
140
142 The jstrftime() function returns the number of characters placed in the
143 array s, not including the terminating null byte, provided the string,
144 including the terminating null byte, fits. Otherwise, it returns max,
145 and the contents of the array is undefined.
146
148 The environment variables TZ and LC_TIME are used.
149
151 C99.
152
154 RFC 2822-compliant date format (with an English locale for %a and %b)
155
156 "%a, %d %b %Y %T %z"
157
158 RFC 822-compliant date format (with an English locale for %a and %b)
159
160 "%a, %d %b %y %T %z"
161
162 Example Program
163 The program below can be used to experiment with jstrftime().
164
165 Some examples of the result string produced by the libjalali implemen‐
166 tation of jstrftime() are as follows:
167
168 $ ./a.out '%m'
169 Result string is "11"
170
171 Here's the program source:
172
173 #include <stdio.h>
174 #include <stdlib.h>
175 #include <time.h>
176 #include <jalali.h>
177 #include <jtime.h>
178
179 int
180 main(int argc, char *argv[])
181 {
182 char outstr[200];
183 time_t t;
184 struct tm *tmp;
185
186 t = time(NULL);
187 tmp = jlocaltime(&t);
188 if (tmp == NULL) {
189 perror("jlocaltime");
190 exit(EXIT_FAILURE);
191 }
192
193 if (jstrftime(outstr, sizeof(outstr), argv[1], tmp) == 0) {
194 fprintf(stderr, "jstrftime returned 0");
195 exit(EXIT_FAILURE);
196 }
197
198 printf("Result string is \"%s\"\n", outstr);
199 exit(EXIT_SUCCESS);
200 }
201
203 jdate(1), jcal(1), time(2), jctime(3), sprintf(3), jstrptime(3)
204
206 This page is part of release 0.2 of the libjalali man-pages
207
209 Written by Ashkan Ghassemi. <ghassemi@ftml.net>
210
212 Report libjalali bugs to <ghassemi@ftml.net>
213
214 libjalali home page: <http://savannah.nongnu.org/projects/jcal/>
215
217 Copyright (C) 2011 Ashkan Ghassemi.
218
219 License LGPLv3+: GNU LGPL version 3 or later
220 <http://gnu.org/licenses/lgpl.html>. This is free software: you are
221 free to change and redistribute it. There is NO WARRANTY, to the extent
222 permitted by law.
223
224
225
226GNU 2011-05-28 JSTRFTIME(3)