1 /* Copyright (C) 1991,92,93,94,95,96,97,98 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
24 # define HAVE_LIMITS_H 1
26 # define HAVE_MBRLEN 1
27 # define HAVE_STRUCT_ERA_ENTRY 1
28 # define HAVE_TM_GMTOFF 1
29 # define HAVE_TM_ZONE 1
30 # define HAVE_TZNAME 1
32 # define MULTIBYTE_IS_FORMAT_SAFE 1
33 # define STDC_HEADERS 1
34 # include "../locale/localeinfo.h"
37 #if defined emacs && !defined HAVE_BCOPY
38 # define HAVE_MEMCPY 1
42 #include <sys/types.h> /* Some systems define `time_t' here. */
44 #ifdef TIME_WITH_SYS_TIME
45 # include <sys/time.h>
48 # ifdef HAVE_SYS_TIME_H
49 # include <sys/time.h>
55 extern char *tzname
[];
58 /* Do multibyte processing if multibytes are supported, unless
59 multibyte sequences are safe in formats. Multibyte sequences are
60 safe if they cannot contain byte sequences that look like format
61 conversion specifications. The GNU C Library uses UTF8 multibyte
62 encoding, which is safe for formats, but strftime.c can be used
63 with other C libraries that use unsafe encodings. */
64 #define DO_MULTIBYTE (HAVE_MBLEN && ! MULTIBYTE_IS_FORMAT_SAFE)
70 /* Simulate mbrlen with mblen as best we can. */
71 # define mbstate_t int
72 # define mbrlen(s, n, ps) mblen (s, n)
73 # define mbsinit(ps) (*(ps) == 0)
75 static const mbstate_t mbstate_zero
;
88 # define memcpy(d, s, n) bcopy ((s), (d), (n))
93 # define MEMPCPY(d, s, n) __mempcpy (d, s, n)
96 # define MEMPCPY(d, s, n) ((void *) ((char *) memcpy (d, s, n) + (n)))
101 # if defined (__GNUC__) || (defined (__STDC__) && __STDC__)
102 # define __P(args) args
104 # define __P(args) ()
106 #endif /* Not __P. */
124 #define TYPE_SIGNED(t) ((t) -1 < 0)
126 /* Bound on length of the string representing an integer value of type t.
127 Subtract one for the sign bit if t is signed;
128 302 / 1000 is log10 (2) rounded up;
129 add one for integer division truncation;
130 add one more for a minus sign if t is signed. */
131 #define INT_STRLEN_BOUND(t) \
132 ((sizeof (t) * CHAR_BIT - TYPE_SIGNED (t)) * 302 / 1000 + 1 + TYPE_SIGNED (t))
134 #define TM_YEAR_BASE 1900
137 /* Nonzero if YEAR is a leap year (every 4 years,
138 except every 100th isn't, and every 400th is). */
139 # define __isleap(year) \
140 ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
145 # define my_strftime_gmtime_r __gmtime_r
146 # define my_strftime_localtime_r __localtime_r
147 # define tzname __tzname
148 # define tzset __tzset
151 /* If we're a strftime substitute in a GNU program, then prefer gmtime
152 to gmtime_r, since many gmtime_r implementations are buggy.
153 Similarly for localtime_r. */
155 # if ! HAVE_TM_GMTOFF
156 static struct tm
*my_strftime_gmtime_r
__P ((const time_t *, struct tm
*));
158 my_strftime_gmtime_r (t
, tp
)
162 struct tm
*l
= gmtime (t
);
168 # endif /* ! HAVE_TM_GMTOFF */
170 static struct tm
*my_strftime_localtime_r
__P ((const time_t *, struct tm
*));
172 my_strftime_localtime_r (t
, tp
)
176 struct tm
*l
= localtime (t
);
182 #endif /* ! defined _LIBC */
185 #if !defined memset && !defined HAVE_MEMSET && !defined _LIBC
186 /* Some systems lack the `memset' function and we don't want to
187 introduce additional dependencies. */
188 /* The SGI compiler reportedly barfs on the trailing null
189 if we use a string constant as the initializer. 28 June 1997, rms. */
190 static const char spaces
[16] = /* " " */
191 { ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ' };
192 static const char zeroes
[16] = /* "0000000000000000" */
193 { '0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0' };
195 # define memset_space(P, Len) \
201 int _this = _len > 16 ? 16 : _len; \
202 (P) = MEMPCPY ((P), spaces, _this); \
208 # define memset_zero(P, Len) \
214 int _this = _len > 16 ? 16 : _len; \
215 (P) = MEMPCPY ((P), zeroes, _this); \
221 # define memset_space(P, Len) (memset ((P), ' ', (Len)), (P) += (Len))
222 # define memset_zero(P, Len) (memset ((P), '0', (Len)), (P) += (Len))
229 int _delta = width - _n; \
230 int _incr = _n + (_delta > 0 ? _delta : 0); \
231 if (i + _incr >= maxsize) \
238 memset_zero (p, _delta); \
240 memset_space (p, _delta); \
251 memcpy_lowcase (p, (s), _n); \
252 else if (to_uppcase) \
253 memcpy_uppcase (p, (s), _n); \
255 memcpy ((PTR) p, (PTR) (s), _n))
260 # define TOUPPER(Ch) toupper (Ch)
261 # define TOLOWER(Ch) tolower (Ch)
263 # define TOUPPER(Ch) (islower (Ch) ? toupper (Ch) : (Ch))
264 # define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
266 /* We don't use `isdigit' here since the locale dependent
267 interpretation is not what we want here. We only need to accept
268 the arabic digits in the ASCII range. One day there is perhaps a
269 more reliable way to accept other sets of digits. */
270 #define ISDIGIT(Ch) ((unsigned int) (Ch) - '0' <= 9)
272 static char *memcpy_lowcase
__P ((char *dest
, const char *src
, size_t len
));
275 memcpy_lowcase (dest
, src
, len
)
281 dest
[len
] = TOLOWER ((unsigned char) src
[len
]);
285 static char *memcpy_uppcase
__P ((char *dest
, const char *src
, size_t len
));
288 memcpy_uppcase (dest
, src
, len
)
294 dest
[len
] = TOUPPER ((unsigned char) src
[len
]);
300 /* Yield the difference between *A and *B,
301 measured in seconds, ignoring leap seconds. */
302 # define tm_diff ftime_tm_diff
303 static int tm_diff
__P ((const struct tm
*, const struct tm
*));
309 /* Compute intervening leap days correctly even if year is negative.
310 Take care to avoid int overflow in leap day calculations,
311 but it's OK to assume that A and B are close to each other. */
312 int a4
= (a
->tm_year
>> 2) + (TM_YEAR_BASE
>> 2) - ! (a
->tm_year
& 3);
313 int b4
= (b
->tm_year
>> 2) + (TM_YEAR_BASE
>> 2) - ! (b
->tm_year
& 3);
314 int a100
= a4
/ 25 - (a4
% 25 < 0);
315 int b100
= b4
/ 25 - (b4
% 25 < 0);
316 int a400
= a100
>> 2;
317 int b400
= b100
>> 2;
318 int intervening_leap_days
= (a4
- b4
) - (a100
- b100
) + (a400
- b400
);
319 int years
= a
->tm_year
- b
->tm_year
;
320 int days
= (365 * years
+ intervening_leap_days
321 + (a
->tm_yday
- b
->tm_yday
));
322 return (60 * (60 * (24 * days
+ (a
->tm_hour
- b
->tm_hour
))
323 + (a
->tm_min
- b
->tm_min
))
324 + (a
->tm_sec
- b
->tm_sec
));
326 #endif /* ! HAVE_TM_GMTOFF */
330 /* The number of days from the first day of the first ISO week of this
331 year to the year day YDAY with week day WDAY. ISO weeks start on
332 Monday; the first ISO week has the year's first Thursday. YDAY may
333 be as small as YDAY_MINIMUM. */
334 #define ISO_WEEK_START_WDAY 1 /* Monday */
335 #define ISO_WEEK1_WDAY 4 /* Thursday */
336 #define YDAY_MINIMUM (-366)
337 static int iso_week_days
__P ((int, int));
342 iso_week_days (yday
, wday
)
346 /* Add enough to the first operand of % to make it nonnegative. */
347 int big_enough_multiple_of_7
= (-YDAY_MINIMUM
/ 7 + 2) * 7;
349 - (yday
- wday
+ ISO_WEEK1_WDAY
+ big_enough_multiple_of_7
) % 7
350 + ISO_WEEK1_WDAY
- ISO_WEEK_START_WDAY
);
354 #if !(defined _NL_CURRENT || HAVE_STRFTIME)
355 static char const weekday_name
[][10] =
357 "Sunday", "Monday", "Tuesday", "Wednesday",
358 "Thursday", "Friday", "Saturday"
360 static char const month_name
[][10] =
362 "January", "February", "March", "April", "May", "June",
363 "July", "August", "September", "October", "November", "December"
369 # define my_strftime emacs_strftimeu
370 # define ut_argument , ut
371 # define ut_argument_spec int ut;
372 # define ut_argument_spec_iso , int ut
374 # define my_strftime strftime
376 # define ut_argument_spec
377 # define ut_argument_spec_iso
378 /* We don't have this information in general. */
382 #if !defined _LIBC && HAVE_TZNAME && HAVE_TZSET
383 /* Solaris 2.5 tzset sometimes modifies the storage returned by localtime.
384 Work around this bug by copying *tp before it might be munged. */
385 size_t _strftime_copytm
__P ((char *, size_t, const char *,
386 const struct tm
* ut_argument_spec_iso
));
388 my_strftime (s
, maxsize
, format
, tp ut_argument
)
397 return _strftime_copytm (s
, maxsize
, format
, &tmcopy ut_argument
);
400 # define my_strftime(S, Maxsize, Format, Tp) \
401 _strftime_copytm (S, Maxsize, Format, Tp)
405 /* Write information from TP into S according to the format
406 string FORMAT, writing no more that MAXSIZE characters
407 (including the terminating '\0') and returning number of
408 characters written. If S is NULL, nothing will be written
409 anywhere, so to determine how many characters would be
410 written, use NULL for S and (size_t) UINT_MAX for MAXSIZE. */
412 my_strftime (s
, maxsize
, format
, tp ut_argument
)
419 int hour12
= tp
->tm_hour
;
421 /* We cannot make the following values variables since we must delay
422 the evaluation of these values until really needed since some
423 expressions might not be valid in every situation. The `struct tm'
424 might be generated by a strptime() call that initialized
425 only a few elements. Dereference the pointers only if the format
426 requires this. Then it is ok to fail if the pointers are invalid. */
427 # define a_wkday _NL_CURRENT (LC_TIME, ABDAY_1 + tp->tm_wday)
428 # define f_wkday _NL_CURRENT (LC_TIME, DAY_1 + tp->tm_wday)
429 # define a_month _NL_CURRENT (LC_TIME, ABMON_1 + tp->tm_mon)
430 # define f_month _NL_CURRENT (LC_TIME, MON_1 + tp->tm_mon)
431 # define ampm _NL_CURRENT (LC_TIME, tp->tm_hour > 11 ? PM_STR : AM_STR)
433 # define aw_len strlen (a_wkday)
434 # define am_len strlen (a_month)
435 # define ap_len strlen (ampm)
438 # define f_wkday (weekday_name[tp->tm_wday])
439 # define f_month (month_name[tp->tm_mon])
440 # define a_wkday f_wkday
441 # define a_month f_month
442 # define ampm ("AMPM" + 2 * (tp->tm_hour > 11))
456 /* The POSIX test suite assumes that setting
457 the environment variable TZ to a new value before calling strftime()
458 will influence the result (the %Z format) even if the information in
459 TP is computed with a totally different time zone.
460 This is bogus: though POSIX allows bad behavior like this,
461 POSIX does not require it. Do the right thing instead. */
462 zone
= (const char *) tp
->tm_zone
;
467 if (! (zone
&& *zone
))
472 /* POSIX.1 8.1.1 requires that whenever strftime() is called, the
473 time zone names contained in the external variable `tzname' shall
474 be set as if the tzset() function had been called. */
487 for (f
= format
; *f
!= '\0'; ++f
)
489 int pad
= 0; /* Padding for number ('-', '_', or 0). */
490 int modifier
; /* Field modifier ('E', 'O', or 0). */
491 int digits
; /* Max digits for numeric format. */
492 int number_value
; /* Numeric value to be printed. */
493 int negative_number
; /* 1 if the number is negative. */
496 char buf
[1 + (sizeof (int) < sizeof (time_t)
497 ? INT_STRLEN_BOUND (time_t)
498 : INT_STRLEN_BOUND (int))];
512 case '\a': case '\b': case '\t': case '\n':
513 case '\v': case '\f': case '\r':
514 case ' ': case '!': case '"': case '#': case '&': case'\'':
515 case '(': case ')': case '*': case '+': case ',': case '-':
516 case '.': case '/': case '0': case '1': case '2': case '3':
517 case '4': case '5': case '6': case '7': case '8': case '9':
518 case ':': case ';': case '<': case '=': case '>': case '?':
519 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
520 case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
521 case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
522 case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
523 case 'Y': case 'Z': case '[': case'\\': case ']': case '^':
524 case '_': case 'a': case 'b': case 'c': case 'd': case 'e':
525 case 'f': case 'g': case 'h': case 'i': case 'j': case 'k':
526 case 'l': case 'm': case 'n': case 'o': case 'p': case 'q':
527 case 'r': case 's': case 't': case 'u': case 'v': case 'w':
528 case 'x': case 'y': case 'z': case '{': case '|': case '}':
530 /* The C Standard requires these 98 characters (plus '%') to
531 be in the basic execution character set. None of these
532 characters can start a multibyte sequence, so they need
533 not be analyzed further. */
538 /* Copy this multibyte sequence until we reach its end, find
539 an error, or come back to the initial shift state. */
541 mbstate_t mbstate
= mbstate_zero
;
546 size_t bytes
= mbrlen (f
+ len
, (size_t) -1, &mbstate
);
551 if (bytes
== (size_t) -2)
553 len
+= strlen (f
+ len
);
557 if (bytes
== (size_t) -1)
565 while (! mbsinit (&mbstate
));
573 #else /* ! DO_MULTIBYTE */
575 /* Either multibyte encodings are not supported, or they are
576 safe for formats, so any non-'%' byte can be copied through. */
583 #endif /* ! DO_MULTIBYTE */
585 /* Check for flags that can modify a format. */
590 /* This influences the number formats. */
597 /* This changes textual output. */
611 /* As a GNU extension we allow to specify the field width. */
621 while (ISDIGIT (*f
));
624 /* Check for modifiers. */
637 /* Now do the specified format. */
641 #define DO_NUMBER(d, v) \
642 digits = width == -1 ? d : width; \
643 number_value = v; goto do_number
644 #define DO_NUMBER_SPACEPAD(d, v) \
645 digits = width == -1 ? d : width; \
646 number_value = v; goto do_number_spacepad
662 #if defined _NL_CURRENT || !HAVE_STRFTIME
663 cpy (aw_len
, a_wkday
);
666 goto underlying_strftime
;
677 #if defined _NL_CURRENT || !HAVE_STRFTIME
678 cpy (strlen (f_wkday
), f_wkday
);
681 goto underlying_strftime
;
685 case 'h': /* POSIX.2 extension. */
688 #if defined _NL_CURRENT || !HAVE_STRFTIME
689 cpy (am_len
, a_month
);
692 goto underlying_strftime
;
703 #if defined _NL_CURRENT || !HAVE_STRFTIME
704 cpy (strlen (f_month
), f_month
);
707 goto underlying_strftime
;
714 if (! (modifier
== 'E'
715 && *(subfmt
= _NL_CURRENT (LC_TIME
, ERA_D_T_FMT
)) != '\0'))
716 subfmt
= _NL_CURRENT (LC_TIME
, D_T_FMT
);
719 goto underlying_strftime
;
721 subfmt
= "%a %b %e %H:%M:%S %Y";
728 size_t len
= my_strftime (NULL
, (size_t) -1, subfmt
, tp
);
729 add (len
, my_strftime (p
, maxsize
- i
, subfmt
, tp
));
732 while (old_start
< p
)
734 *old_start
= TOUPPER ((unsigned char) *old_start
);
740 #if HAVE_STRFTIME && ! (defined _NL_CURRENT && HAVE_STRUCT_ERA_ENTRY)
743 /* The relevant information is available only via the
744 underlying strftime implementation, so use that. */
747 char ubuf
[1024]; /* enough for any single format in practice */
754 len
= strftime (ubuf
, sizeof ubuf
, ufmt
, tp
);
755 if (len
== 0 && ubuf
[0] != '\0')
762 case 'C': /* POSIX.2 extension. */
767 #if HAVE_STRUCT_ERA_ENTRY
768 struct era_entry
*era
= _nl_get_era_entry (tp
);
771 size_t len
= strlen (era
->name_fmt
);
772 cpy (len
, era
->name_fmt
);
777 goto underlying_strftime
;
783 int year
= tp
->tm_year
+ TM_YEAR_BASE
;
784 DO_NUMBER (1, year
/ 100 - (year
% 100 < 0));
791 if (! (modifier
== 'E'
792 && *(subfmt
= _NL_CURRENT (LC_TIME
, ERA_D_FMT
)) != '\0'))
793 subfmt
= _NL_CURRENT (LC_TIME
, D_FMT
);
797 goto underlying_strftime
;
802 case 'D': /* POSIX.2 extension. */
812 DO_NUMBER (2, tp
->tm_mday
);
814 case 'e': /* POSIX.2 extension. */
818 DO_NUMBER_SPACEPAD (2, tp
->tm_mday
);
820 /* All numeric formats set DIGITS and NUMBER_VALUE and then
821 jump to one of these two labels. */
824 /* Force `_' flag unless overwritten by `0' flag. */
829 /* Format the number according to the MODIFIER flag. */
831 if (modifier
== 'O' && 0 <= number_value
)
834 /* Get the locale specific alternate representation of
835 the number NUMBER_VALUE. If none exist NULL is returned. */
836 const char *cp
= _nl_get_alt_digit (number_value
);
840 size_t digitlen
= strlen (cp
);
849 goto underlying_strftime
;
854 unsigned int u
= number_value
;
856 bufp
= buf
+ sizeof (buf
);
857 negative_number
= number_value
< 0;
863 *--bufp
= u
% 10 + '0';
864 while ((u
/= 10) != 0);
867 do_number_sign_and_padding
:
873 int padding
= digits
- (buf
+ sizeof (buf
) - bufp
);
877 while (0 < padding
--)
882 bufp
+= negative_number
;
883 while (0 < padding
--)
890 cpy (buf
+ sizeof (buf
) - bufp
, bufp
);
903 DO_NUMBER (2, tp
->tm_hour
);
909 DO_NUMBER (2, hour12
);
911 case 'k': /* GNU extension. */
915 DO_NUMBER_SPACEPAD (2, tp
->tm_hour
);
917 case 'l': /* GNU extension. */
921 DO_NUMBER_SPACEPAD (2, hour12
);
927 DO_NUMBER (3, 1 + tp
->tm_yday
);
933 DO_NUMBER (2, tp
->tm_min
);
939 DO_NUMBER (2, tp
->tm_mon
+ 1);
941 case 'n': /* POSIX.2 extension. */
947 #if !defined _NL_CURRENT && HAVE_STRFTIME
958 #if defined _NL_CURRENT || !HAVE_STRFTIME
962 goto underlying_strftime
;
965 case 'R': /* GNU extension. */
969 case 'r': /* POSIX.2 extension. */
971 if (*(subfmt
= _NL_CURRENT (LC_TIME
, T_FMT_AMPM
)) == '\0')
973 subfmt
= "%I:%M:%S %p";
980 DO_NUMBER (2, tp
->tm_sec
);
982 case 's': /* GNU extension. */
990 /* Generate string value for T using time_t arithmetic;
991 this works even if sizeof (long) < sizeof (time_t). */
993 bufp
= buf
+ sizeof (buf
);
994 negative_number
= t
< 0;
1001 if (negative_number
)
1005 /* Adjust if division truncates to minus infinity. */
1006 if (0 < -1 % 10 && d
< 0)
1018 goto do_number_sign_and_padding
;
1022 if (modifier
== 'O')
1025 if (! (modifier
== 'E'
1026 && *(subfmt
= _NL_CURRENT (LC_TIME
, ERA_T_FMT
)) != '\0'))
1027 subfmt
= _NL_CURRENT (LC_TIME
, T_FMT
);
1031 goto underlying_strftime
;
1036 case 'T': /* POSIX.2 extension. */
1037 subfmt
= "%H:%M:%S";
1040 case 't': /* POSIX.2 extension. */
1045 case 'u': /* POSIX.2 extension. */
1046 DO_NUMBER (1, (tp
->tm_wday
- 1 + 7) % 7 + 1);
1049 if (modifier
== 'E')
1052 DO_NUMBER (2, (tp
->tm_yday
- tp
->tm_wday
+ 7) / 7);
1055 case 'g': /* GNU extension. */
1056 case 'G': /* GNU extension. */
1057 if (modifier
== 'E')
1060 int year
= tp
->tm_year
+ TM_YEAR_BASE
;
1061 int days
= iso_week_days (tp
->tm_yday
, tp
->tm_wday
);
1065 /* This ISO week belongs to the previous year. */
1067 days
= iso_week_days (tp
->tm_yday
+ (365 + __isleap (year
)),
1072 int d
= iso_week_days (tp
->tm_yday
- (365 + __isleap (year
)),
1076 /* This ISO week belongs to the next year. */
1085 DO_NUMBER (2, (year
% 100 + 100) % 100);
1088 DO_NUMBER (1, year
);
1091 DO_NUMBER (2, days
/ 7 + 1);
1096 if (modifier
== 'E')
1099 DO_NUMBER (2, (tp
->tm_yday
- (tp
->tm_wday
- 1 + 7) % 7 + 7) / 7);
1102 if (modifier
== 'E')
1105 DO_NUMBER (1, tp
->tm_wday
);
1108 if (modifier
== 'E')
1110 #if HAVE_STRUCT_ERA_ENTRY
1111 struct era_entry
*era
= _nl_get_era_entry (tp
);
1114 subfmt
= strchr (era
->name_fmt
, '\0') + 1;
1119 goto underlying_strftime
;
1123 if (modifier
== 'O')
1126 DO_NUMBER (1, tp
->tm_year
+ TM_YEAR_BASE
);
1129 if (modifier
== 'E')
1131 #if HAVE_STRUCT_ERA_ENTRY
1132 struct era_entry
*era
= _nl_get_era_entry (tp
);
1135 int delta
= tp
->tm_year
- era
->start_date
[0];
1136 DO_NUMBER (1, (era
->offset
1137 + (era
->direction
== '-' ? -delta
: delta
)));
1141 goto underlying_strftime
;
1145 DO_NUMBER (2, (tp
->tm_year
% 100 + 100) % 100);
1155 /* The tzset() call might have changed the value. */
1156 if (!(zone
&& *zone
) && tp
->tm_isdst
>= 0)
1157 zone
= tzname
[tp
->tm_isdst
];
1160 zone
= ""; /* POSIX.2 requires the empty string here. */
1162 cpy (strlen (zone
), zone
);
1165 case 'z': /* GNU extension. */
1166 if (tp
->tm_isdst
< 0)
1172 diff
= tp
->tm_gmtoff
;
1185 if (lt
== (time_t) -1)
1187 /* mktime returns -1 for errors, but -1 is also a
1188 valid time_t value. Check whether an error really
1192 if (! my_strftime_localtime_r (<
, &tm
)
1193 || ((ltm
.tm_sec
^ tm
.tm_sec
)
1194 | (ltm
.tm_min
^ tm
.tm_min
)
1195 | (ltm
.tm_hour
^ tm
.tm_hour
)
1196 | (ltm
.tm_mday
^ tm
.tm_mday
)
1197 | (ltm
.tm_mon
^ tm
.tm_mon
)
1198 | (ltm
.tm_year
^ tm
.tm_year
)))
1202 if (! my_strftime_gmtime_r (<
, >m
))
1205 diff
= tm_diff (<m
, >m
);
1218 DO_NUMBER (4, (diff
/ 60) * 100 + diff
% 60);
1221 case '\0': /* GNU extension: % at end of format. */
1225 /* Unknown format; output the format, including the '%',
1226 since this is most likely the right thing to do if a
1227 multibyte string has been misparsed. */
1231 for (flen
= 1; f
[1 - flen
] != '%'; flen
++)
1233 cpy (flen
, &f
[1 - flen
]);
1239 if (p
&& i
< maxsize
)
1246 /* For Emacs we have a separate interface which corresponds to the normal
1247 strftime function and does not have the extra information whether the
1248 TP arguments comes from a `gmtime' call or not. */
1250 emacs_strftime (s
, maxsize
, format
, tp
)
1254 const struct tm
*tp
;
1256 return my_strftime (s
, maxsize
, format
, tp
, 0);