aboutsummaryrefslogtreecommitdiffstats
path: root/lib/strftime.h
diff options
context:
space:
mode:
authorPaul Eggert2024-02-14 21:18:25 -0800
committerPaul Eggert2024-02-14 22:05:06 -0800
commit377e4212e9df293ba2021238bae2bdccf5c8b8d3 (patch)
tree7bafb4a397e147ba6a765da26a36858146ebd5f5 /lib/strftime.h
parent7c32f3bcd6d390510d9463b3100255cecab41e1c (diff)
downloademacs-377e4212e9df293ba2021238bae2bdccf5c8b8d3.tar.gz
emacs-377e4212e9df293ba2021238bae2bdccf5c8b8d3.zip
Update from Gnulib by running admin/merge-gnulib
* lib/strftime.c: New file, copied from Gnulib.
Diffstat (limited to 'lib/strftime.h')
-rw-r--r--lib/strftime.h73
1 files changed, 62 insertions, 11 deletions
diff --git a/lib/strftime.h b/lib/strftime.h
index d6efdb848a3..8ce62cdb6d7 100644
--- a/lib/strftime.h
+++ b/lib/strftime.h
@@ -21,17 +21,68 @@
21extern "C" { 21extern "C" {
22#endif 22#endif
23 23
24/* Just like strftime, but with two more arguments: 24/* Formats the broken-down time *__TP, with additional __NS nanoseconds,
25 POSIX requires that strftime use the local timezone information. 25 into the buffer __S of size __MAXSIZE, according to the rules of the
26 Use the timezone __TZ instead. Use __NS as the number of 26 LC_TIME category of the current locale.
27 nanoseconds in the %N directive. 27
28 28 Uses the time zone __TZ.
29 On error, set errno and return 0. Otherwise, return the number of 29 If *__TP represents local time, __TZ should be set to
30 bytes generated (not counting the trailing NUL), preserving errno 30 tzalloc (getenv ("TZ")).
31 if the number is 0. This errno behavior is in draft POSIX 202x 31 If *__TP represents universal time (a.k.a. GMT), __TZ should be set to
32 plus some requested changes to POSIX. */ 32 (timezone_t) 0.
33size_t nstrftime (char *restrict, size_t, char const *, struct tm const *, 33
34 timezone_t __tz, int __ns); 34 The format string __FORMAT, including GNU extensions, is described in
35 the GNU libc's strftime() documentation:
36 <https://www.gnu.org/software/libc/manual/html_node/Formatting-Calendar-Time.html>
37 Additionally, the following conversion is supported:
38 %N The number of nanoseconds, passed as __NS argument.
39 Here's a summary of the available conversions (= format directives):
40 literal characters %n %t %%
41 date:
42 century %C
43 year %Y %y
44 week-based year %G %g
45 month (in year) %m %B %b %h
46 week in year %U %W %V
47 day in year %j
48 day (in month) %d %e
49 day in week %u %w %A %a
50 year, month, day %x %F %D
51 time:
52 half-day %p %P
53 hour %H %k %I %l
54 minute (in hour) %M
55 hour, minute %R
56 second (in minute) %S
57 hour, minute, second %r %T %X
58 second (since epoch) %s
59 date and time: %c
60 time zone: %z %Z
61 nanosecond %N
62
63 Stores the result, as a string with a trailing NUL character, at the
64 beginning of the array __S[0..__MAXSIZE-1], if it fits, and returns
65 the length of that string, not counting the trailing NUL. In this case,
66 errno is preserved if the return value is 0.
67 If it does not fit, this function sets errno to ERANGE and returns 0.
68 Upon other errors, this function sets errno and returns 0 as well.
69
70 Note: The errno behavior is in draft POSIX 202x plus some requested
71 changes to POSIX.
72
73 This function is like strftime, but with two more arguments:
74 * __TZ instead of the local timezone information,
75 * __NS as the number of nanoseconds in the %N directive.
76 */
77size_t nstrftime (char *restrict __s, size_t __maxsize,
78 char const *__format,
79 struct tm const *__tp, timezone_t __tz, int __ns);
80
81/* Like nstrftime, except that it uses the "C" locale instead of the
82 current locale. */
83size_t c_nstrftime (char *restrict __s, size_t __maxsize,
84 char const *__format,
85 struct tm const *__tp, timezone_t __tz, int __ns);
35 86
36#ifdef __cplusplus 87#ifdef __cplusplus
37} 88}