1 /* Copyright (C) 1991,92,93,94,95,96,97,98,99 Free Software Foundation, Inc.
3 NOTE: The canonical source of this file is maintained with the GNU C Library.
4 Bugs can be reported to bug-glibc@prep.ai.mit.edu.
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
26 # define HAVE_LIMITS_H 1
28 # define HAVE_MBRLEN 1
29 # define HAVE_STRUCT_ERA_ENTRY 1
30 # define HAVE_TM_GMTOFF 1
31 # define HAVE_TM_ZONE 1
32 # define HAVE_TZNAME 1
34 # define MULTIBYTE_IS_FORMAT_SAFE 1
35 # define STDC_HEADERS 1
36 # include "../locale/localeinfo.h"
39 #if defined emacs && !defined HAVE_BCOPY
40 # define HAVE_MEMCPY 1
44 #include <sys/types.h> /* Some systems define `time_t' here. */
46 #ifdef TIME_WITH_SYS_TIME
47 # include <sys/time.h>
50 # ifdef HAVE_SYS_TIME_H
51 # include <sys/time.h>
57 extern char *tzname
[];
60 /* Do multibyte processing if multibytes are supported, unless
61 multibyte sequences are safe in formats. Multibyte sequences are
62 safe if they cannot contain byte sequences that look like format
63 conversion specifications. The GNU C Library uses UTF8 multibyte
64 encoding, which is safe for formats, but strftime.c can be used
65 with other C libraries that use unsafe encodings. */
66 #define DO_MULTIBYTE (HAVE_MBLEN && ! MULTIBYTE_IS_FORMAT_SAFE)
72 /* Simulate mbrlen with mblen as best we can. */
73 # define mbstate_t int
74 # define mbrlen(s, n, ps) mblen (s, n)
75 # define mbsinit(ps) (*(ps) == 0)
77 static const mbstate_t mbstate_zero
;
90 # define memcpy(d, s, n) bcopy ((s), (d), (n))
95 # define MEMPCPY(d, s, n) __mempcpy (d, s, n)
98 # define MEMPCPY(d, s, n) ((void *) ((char *) memcpy (d, s, n) + (n)))
103 # if defined __GNUC__ || (defined __STDC__ && __STDC__)
104 # define __P(args) args
106 # define __P(args) ()
108 #endif /* Not __P. */
126 #define TYPE_SIGNED(t) ((t) -1 < 0)
128 /* Bound on length of the string representing an integer value of type t.
129 Subtract one for the sign bit if t is signed;
130 302 / 1000 is log10 (2) rounded up;
131 add one for integer division truncation;
132 add one more for a minus sign if t is signed. */
133 #define INT_STRLEN_BOUND(t) \
134 ((sizeof (t) * CHAR_BIT - TYPE_SIGNED (t)) * 302 / 1000 + 1 + TYPE_SIGNED (t))
136 #define TM_YEAR_BASE 1900
139 /* Nonzero if YEAR is a leap year (every 4 years,
140 except every 100th isn't, and every 400th is). */
141 # define __isleap(year) \
142 ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
147 # define my_strftime_gmtime_r __gmtime_r
148 # define my_strftime_localtime_r __localtime_r
149 # define tzname __tzname
150 # define tzset __tzset
153 /* If we're a strftime substitute in a GNU program, then prefer gmtime
154 to gmtime_r, since many gmtime_r implementations are buggy.
155 Similarly for localtime_r. */
157 # if ! HAVE_TM_GMTOFF
158 static struct tm
*my_strftime_gmtime_r
__P ((const time_t *, struct tm
*));
160 my_strftime_gmtime_r (const time_t *t
, struct tm
*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 (const time_t *t
, struct tm
*tp
)
174 struct tm
*l
= localtime (t
);
180 #endif /* ! defined _LIBC */
183 #if !defined memset && !defined HAVE_MEMSET && !defined _LIBC
184 /* Some systems lack the `memset' function and we don't want to
185 introduce additional dependencies. */
186 /* The SGI compiler reportedly barfs on the trailing null
187 if we use a string constant as the initializer. 28 June 1997, rms. */
188 static const char spaces
[16] = /* " " */
189 { ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ' };
190 static const char zeroes
[16] = /* "0000000000000000" */
191 { '0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0' };
193 # define memset_space(P, Len) \
199 int _this = _len > 16 ? 16 : _len; \
200 (P) = MEMPCPY ((P), spaces, _this); \
206 # define memset_zero(P, Len) \
212 int _this = _len > 16 ? 16 : _len; \
213 (P) = MEMPCPY ((P), zeroes, _this); \
219 # define memset_space(P, Len) (memset ((P), ' ', (Len)), (P) += (Len))
220 # define memset_zero(P, Len) (memset ((P), '0', (Len)), (P) += (Len))
227 int _delta = width - _n; \
228 int _incr = _n + (_delta > 0 ? _delta : 0); \
229 if (i + _incr >= maxsize) \
236 memset_zero (p, _delta); \
238 memset_space (p, _delta); \
249 memcpy_lowcase (p, (s), _n); \
250 else if (to_uppcase) \
251 memcpy_uppcase (p, (s), _n); \
253 memcpy ((PTR) p, (PTR) (s), _n))
258 # define TOUPPER(Ch) toupper (Ch)
259 # define TOLOWER(Ch) tolower (Ch)
261 # define TOUPPER(Ch) (islower (Ch) ? toupper (Ch) : (Ch))
262 # define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
264 /* We don't use `isdigit' here since the locale dependent
265 interpretation is not what we want here. We only need to accept
266 the arabic digits in the ASCII range. One day there is perhaps a
267 more reliable way to accept other sets of digits. */
268 #define ISDIGIT(Ch) ((unsigned int) (Ch) - '0' <= 9)
270 static char *memcpy_lowcase
__P ((char *dest
, const char *src
, size_t len
));
273 memcpy_lowcase (char *dest
, const char *src
, size_t len
)
276 dest
[len
] = TOLOWER ((unsigned char) src
[len
]);
280 static char *memcpy_uppcase
__P ((char *dest
, const char *src
, size_t len
));
283 memcpy_uppcase (char *dest
, const char *src
, size_t len
)
286 dest
[len
] = TOUPPER ((unsigned char) src
[len
]);
292 /* Yield the difference between *A and *B,
293 measured in seconds, ignoring leap seconds. */
294 # define tm_diff ftime_tm_diff
295 static int tm_diff
__P ((const struct tm
*, const struct tm
*));
297 tm_diff (const struct tm
*a
, const struct tm
*b
)
299 /* Compute intervening leap days correctly even if year is negative.
300 Take care to avoid int overflow in leap day calculations,
301 but it's OK to assume that A and B are close to each other. */
302 int a4
= (a
->tm_year
>> 2) + (TM_YEAR_BASE
>> 2) - ! (a
->tm_year
& 3);
303 int b4
= (b
->tm_year
>> 2) + (TM_YEAR_BASE
>> 2) - ! (b
->tm_year
& 3);
304 int a100
= a4
/ 25 - (a4
% 25 < 0);
305 int b100
= b4
/ 25 - (b4
% 25 < 0);
306 int a400
= a100
>> 2;
307 int b400
= b100
>> 2;
308 int intervening_leap_days
= (a4
- b4
) - (a100
- b100
) + (a400
- b400
);
309 int years
= a
->tm_year
- b
->tm_year
;
310 int days
= (365 * years
+ intervening_leap_days
311 + (a
->tm_yday
- b
->tm_yday
));
312 return (60 * (60 * (24 * days
+ (a
->tm_hour
- b
->tm_hour
))
313 + (a
->tm_min
- b
->tm_min
))
314 + (a
->tm_sec
- b
->tm_sec
));
316 #endif /* ! HAVE_TM_GMTOFF */
320 /* The number of days from the first day of the first ISO week of this
321 year to the year day YDAY with week day WDAY. ISO weeks start on
322 Monday; the first ISO week has the year's first Thursday. YDAY may
323 be as small as YDAY_MINIMUM. */
324 #define ISO_WEEK_START_WDAY 1 /* Monday */
325 #define ISO_WEEK1_WDAY 4 /* Thursday */
326 #define YDAY_MINIMUM (-366)
327 static int iso_week_days
__P ((int, int));
332 iso_week_days (int yday
, int wday
)
334 /* Add enough to the first operand of % to make it nonnegative. */
335 int big_enough_multiple_of_7
= (-YDAY_MINIMUM
/ 7 + 2) * 7;
337 - (yday
- wday
+ ISO_WEEK1_WDAY
+ big_enough_multiple_of_7
) % 7
338 + ISO_WEEK1_WDAY
- ISO_WEEK_START_WDAY
);
342 #if !(defined _NL_CURRENT || HAVE_STRFTIME)
343 static char const weekday_name
[][10] =
345 "Sunday", "Monday", "Tuesday", "Wednesday",
346 "Thursday", "Friday", "Saturday"
348 static char const month_name
[][10] =
350 "January", "February", "March", "April", "May", "June",
351 "July", "August", "September", "October", "November", "December"
357 # define my_strftime emacs_strftimeu
358 # define ut_argument , ut
359 # define ut_argument_spec int ut;
360 # define ut_argument_spec_iso , int ut
362 # define my_strftime strftime
364 # define ut_argument_spec
365 # define ut_argument_spec_iso
366 /* We don't have this information in general. */
370 #if !defined _LIBC && HAVE_TZNAME && HAVE_TZSET
371 /* Solaris 2.5 tzset sometimes modifies the storage returned by localtime.
372 Work around this bug by copying *tp before it might be munged. */
373 size_t _strftime_copytm
__P ((char *, size_t, const char *,
374 const struct tm
* ut_argument_spec_iso
));
376 my_strftime (s
, maxsize
, format
, tp ut_argument
)
385 return _strftime_copytm (s
, maxsize
, format
, &tmcopy ut_argument
);
388 # define my_strftime(S, Maxsize, Format, Tp) \
389 _strftime_copytm (S, Maxsize, Format, Tp)
393 /* Write information from TP into S according to the format
394 string FORMAT, writing no more that MAXSIZE characters
395 (including the terminating '\0') and returning number of
396 characters written. If S is NULL, nothing will be written
397 anywhere, so to determine how many characters would be
398 written, use NULL for S and (size_t) UINT_MAX for MAXSIZE. */
400 my_strftime (char *s
, size_t maxsize
, const char *format
, const struct tm
*tp
403 int hour12
= tp
->tm_hour
;
405 /* We cannot make the following values variables since we must delay
406 the evaluation of these values until really needed since some
407 expressions might not be valid in every situation. The `struct tm'
408 might be generated by a strptime() call that initialized
409 only a few elements. Dereference the pointers only if the format
410 requires this. Then it is ok to fail if the pointers are invalid. */
411 # define a_wkday _NL_CURRENT (LC_TIME, ABDAY_1 + tp->tm_wday)
412 # define f_wkday _NL_CURRENT (LC_TIME, DAY_1 + tp->tm_wday)
413 # define a_month _NL_CURRENT (LC_TIME, ABMON_1 + tp->tm_mon)
414 # define f_month _NL_CURRENT (LC_TIME, MON_1 + tp->tm_mon)
415 # define ampm _NL_CURRENT (LC_TIME, tp->tm_hour > 11 ? PM_STR : AM_STR)
417 # define aw_len strlen (a_wkday)
418 # define am_len strlen (a_month)
419 # define ap_len strlen (ampm)
422 # define f_wkday (weekday_name[tp->tm_wday])
423 # define f_month (month_name[tp->tm_mon])
424 # define a_wkday f_wkday
425 # define a_month f_month
426 # define ampm ("AMPM" + 2 * (tp->tm_hour > 11))
440 /* The POSIX test suite assumes that setting
441 the environment variable TZ to a new value before calling strftime()
442 will influence the result (the %Z format) even if the information in
443 TP is computed with a totally different time zone.
444 This is bogus: though POSIX allows bad behavior like this,
445 POSIX does not require it. Do the right thing instead. */
446 zone
= (const char *) tp
->tm_zone
;
451 if (! (zone
&& *zone
))
456 /* POSIX.1 8.1.1 requires that whenever strftime() is called, the
457 time zone names contained in the external variable `tzname' shall
458 be set as if the tzset() function had been called. */
471 for (f
= format
; *f
!= '\0'; ++f
)
473 int pad
= 0; /* Padding for number ('-', '_', or 0). */
474 int modifier
; /* Field modifier ('E', 'O', or 0). */
475 int digits
; /* Max digits for numeric format. */
476 int number_value
; /* Numeric value to be printed. */
477 int negative_number
; /* 1 if the number is negative. */
480 char buf
[1 + (sizeof (int) < sizeof (time_t)
481 ? INT_STRLEN_BOUND (time_t)
482 : INT_STRLEN_BOUND (int))];
496 case '\b': case '\t': case '\n':
497 case '\v': case '\f': case '\r':
498 case ' ': case '!': case '"': case '#': case '&': case'\'':
499 case '(': case ')': case '*': case '+': case ',': case '-':
500 case '.': case '/': case '0': case '1': case '2': case '3':
501 case '4': case '5': case '6': case '7': case '8': case '9':
502 case ':': case ';': case '<': case '=': case '>': case '?':
503 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
504 case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
505 case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
506 case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
507 case 'Y': case 'Z': case '[': case'\\': case ']': case '^':
508 case '_': case 'a': case 'b': case 'c': case 'd': case 'e':
509 case 'f': case 'g': case 'h': case 'i': case 'j': case 'k':
510 case 'l': case 'm': case 'n': case 'o': case 'p': case 'q':
511 case 'r': case 's': case 't': case 'u': case 'v': case 'w':
512 case 'x': case 'y': case 'z': case '{': case '|': case '}':
514 /* The C Standard requires these 97 characters (plus '%', '\a') to
515 be in the basic execution character set. None of these
516 characters can start a multibyte sequence, so they need
517 not be analyzed further. Some old compilers object to
518 '\a', so don't bother optimizing for it. */
523 /* Copy this multibyte sequence until we reach its end, find
524 an error, or come back to the initial shift state. */
526 mbstate_t mbstate
= mbstate_zero
;
531 size_t bytes
= mbrlen (f
+ len
, (size_t) -1, &mbstate
);
536 if (bytes
== (size_t) -2)
538 len
+= strlen (f
+ len
);
542 if (bytes
== (size_t) -1)
550 while (! mbsinit (&mbstate
));
558 #else /* ! DO_MULTIBYTE */
560 /* Either multibyte encodings are not supported, or they are
561 safe for formats, so any non-'%' byte can be copied through. */
568 #endif /* ! DO_MULTIBYTE */
570 /* Check for flags that can modify a format. */
575 /* This influences the number formats. */
582 /* This changes textual output. */
596 /* As a GNU extension we allow to specify the field width. */
606 while (ISDIGIT (*f
));
609 /* Check for modifiers. */
622 /* Now do the specified format. */
626 #define DO_NUMBER(d, v) \
627 digits = width == -1 ? d : width; \
628 number_value = v; goto do_number
629 #define DO_NUMBER_SPACEPAD(d, v) \
630 digits = width == -1 ? d : width; \
631 number_value = v; goto do_number_spacepad
647 #if defined _NL_CURRENT || !HAVE_STRFTIME
648 cpy (aw_len
, a_wkday
);
651 goto underlying_strftime
;
662 #if defined _NL_CURRENT || !HAVE_STRFTIME
663 cpy (strlen (f_wkday
), f_wkday
);
666 goto underlying_strftime
;
670 case 'h': /* POSIX.2 extension. */
673 #if defined _NL_CURRENT || !HAVE_STRFTIME
674 cpy (am_len
, a_month
);
677 goto underlying_strftime
;
688 #if defined _NL_CURRENT || !HAVE_STRFTIME
689 cpy (strlen (f_month
), f_month
);
692 goto underlying_strftime
;
699 if (! (modifier
== 'E'
700 && *(subfmt
= _NL_CURRENT (LC_TIME
, ERA_D_T_FMT
)) != '\0'))
701 subfmt
= _NL_CURRENT (LC_TIME
, D_T_FMT
);
704 goto underlying_strftime
;
706 subfmt
= "%a %b %e %H:%M:%S %Y";
713 size_t len
= my_strftime (NULL
, (size_t) -1, subfmt
, tp
);
714 add (len
, my_strftime (p
, maxsize
- i
, subfmt
, tp
));
717 while (old_start
< p
)
719 *old_start
= TOUPPER ((unsigned char) *old_start
);
725 #if HAVE_STRFTIME && ! (defined _NL_CURRENT && HAVE_STRUCT_ERA_ENTRY)
728 /* The relevant information is available only via the
729 underlying strftime implementation, so use that. */
732 char ubuf
[1024]; /* enough for any single format in practice */
739 len
= strftime (ubuf
, sizeof ubuf
, ufmt
, tp
);
740 if (len
== 0 && ubuf
[0] != '\0')
747 case 'C': /* POSIX.2 extension. */
752 #if HAVE_STRUCT_ERA_ENTRY
753 struct era_entry
*era
= _nl_get_era_entry (tp
);
756 size_t len
= strlen (era
->name_fmt
);
757 cpy (len
, era
->name_fmt
);
762 goto underlying_strftime
;
768 int year
= tp
->tm_year
+ TM_YEAR_BASE
;
769 DO_NUMBER (1, year
/ 100 - (year
% 100 < 0));
776 if (! (modifier
== 'E'
777 && *(subfmt
= _NL_CURRENT (LC_TIME
, ERA_D_FMT
)) != '\0'))
778 subfmt
= _NL_CURRENT (LC_TIME
, D_FMT
);
782 goto underlying_strftime
;
787 case 'D': /* POSIX.2 extension. */
797 DO_NUMBER (2, tp
->tm_mday
);
799 case 'e': /* POSIX.2 extension. */
803 DO_NUMBER_SPACEPAD (2, tp
->tm_mday
);
805 /* All numeric formats set DIGITS and NUMBER_VALUE and then
806 jump to one of these two labels. */
809 /* Force `_' flag unless overwritten by `0' flag. */
814 /* Format the number according to the MODIFIER flag. */
816 if (modifier
== 'O' && 0 <= number_value
)
819 /* Get the locale specific alternate representation of
820 the number NUMBER_VALUE. If none exist NULL is returned. */
821 const char *cp
= _nl_get_alt_digit (number_value
);
825 size_t digitlen
= strlen (cp
);
834 goto underlying_strftime
;
839 unsigned int u
= number_value
;
841 bufp
= buf
+ sizeof (buf
);
842 negative_number
= number_value
< 0;
848 *--bufp
= u
% 10 + '0';
849 while ((u
/= 10) != 0);
852 do_number_sign_and_padding
:
858 int padding
= digits
- (buf
+ sizeof (buf
) - bufp
);
862 while (0 < padding
--)
867 bufp
+= negative_number
;
868 while (0 < padding
--)
875 cpy (buf
+ sizeof (buf
) - bufp
, bufp
);
888 DO_NUMBER (2, tp
->tm_hour
);
894 DO_NUMBER (2, hour12
);
896 case 'k': /* GNU extension. */
900 DO_NUMBER_SPACEPAD (2, tp
->tm_hour
);
902 case 'l': /* GNU extension. */
906 DO_NUMBER_SPACEPAD (2, hour12
);
912 DO_NUMBER (3, 1 + tp
->tm_yday
);
918 DO_NUMBER (2, tp
->tm_min
);
924 DO_NUMBER (2, tp
->tm_mon
+ 1);
926 case 'n': /* POSIX.2 extension. */
932 #if !defined _NL_CURRENT && HAVE_STRFTIME
943 #if defined _NL_CURRENT || !HAVE_STRFTIME
947 goto underlying_strftime
;
950 case 'R': /* GNU extension. */
954 case 'r': /* POSIX.2 extension. */
956 if (*(subfmt
= _NL_CURRENT (LC_TIME
, T_FMT_AMPM
)) == '\0')
958 subfmt
= "%I:%M:%S %p";
965 DO_NUMBER (2, tp
->tm_sec
);
967 case 's': /* GNU extension. */
975 /* Generate string value for T using time_t arithmetic;
976 this works even if sizeof (long) < sizeof (time_t). */
978 bufp
= buf
+ sizeof (buf
);
979 negative_number
= t
< 0;
990 /* Adjust if division truncates to minus infinity. */
991 if (0 < -1 % 10 && d
< 0)
1003 goto do_number_sign_and_padding
;
1007 if (modifier
== 'O')
1010 if (! (modifier
== 'E'
1011 && *(subfmt
= _NL_CURRENT (LC_TIME
, ERA_T_FMT
)) != '\0'))
1012 subfmt
= _NL_CURRENT (LC_TIME
, T_FMT
);
1016 goto underlying_strftime
;
1021 case 'T': /* POSIX.2 extension. */
1022 subfmt
= "%H:%M:%S";
1025 case 't': /* POSIX.2 extension. */
1029 case 'u': /* POSIX.2 extension. */
1030 DO_NUMBER (1, (tp
->tm_wday
- 1 + 7) % 7 + 1);
1033 if (modifier
== 'E')
1036 DO_NUMBER (2, (tp
->tm_yday
- tp
->tm_wday
+ 7) / 7);
1039 case 'g': /* GNU extension. */
1040 case 'G': /* GNU extension. */
1041 if (modifier
== 'E')
1044 int year
= tp
->tm_year
+ TM_YEAR_BASE
;
1045 int days
= iso_week_days (tp
->tm_yday
, tp
->tm_wday
);
1049 /* This ISO week belongs to the previous year. */
1051 days
= iso_week_days (tp
->tm_yday
+ (365 + __isleap (year
)),
1056 int d
= iso_week_days (tp
->tm_yday
- (365 + __isleap (year
)),
1060 /* This ISO week belongs to the next year. */
1069 DO_NUMBER (2, (year
% 100 + 100) % 100);
1072 DO_NUMBER (1, year
);
1075 DO_NUMBER (2, days
/ 7 + 1);
1080 if (modifier
== 'E')
1083 DO_NUMBER (2, (tp
->tm_yday
- (tp
->tm_wday
- 1 + 7) % 7 + 7) / 7);
1086 if (modifier
== 'E')
1089 DO_NUMBER (1, tp
->tm_wday
);
1092 if (modifier
== 'E')
1094 #if HAVE_STRUCT_ERA_ENTRY
1095 struct era_entry
*era
= _nl_get_era_entry (tp
);
1098 subfmt
= strchr (era
->name_fmt
, '\0') + 1;
1103 goto underlying_strftime
;
1107 if (modifier
== 'O')
1110 DO_NUMBER (1, tp
->tm_year
+ TM_YEAR_BASE
);
1113 if (modifier
== 'E')
1115 #if HAVE_STRUCT_ERA_ENTRY
1116 struct era_entry
*era
= _nl_get_era_entry (tp
);
1119 int delta
= tp
->tm_year
- era
->start_date
[0];
1120 DO_NUMBER (1, (era
->offset
1121 + (era
->direction
== '-' ? -delta
: delta
)));
1125 goto underlying_strftime
;
1129 DO_NUMBER (2, (tp
->tm_year
% 100 + 100) % 100);
1139 /* The tzset() call might have changed the value. */
1140 if (!(zone
&& *zone
) && tp
->tm_isdst
>= 0)
1141 zone
= tzname
[tp
->tm_isdst
];
1144 zone
= ""; /* POSIX.2 requires the empty string here. */
1146 cpy (strlen (zone
), zone
);
1149 case 'z': /* GNU extension. */
1150 if (tp
->tm_isdst
< 0)
1156 diff
= tp
->tm_gmtoff
;
1169 if (lt
== (time_t) -1)
1171 /* mktime returns -1 for errors, but -1 is also a
1172 valid time_t value. Check whether an error really
1176 if (! my_strftime_localtime_r (<
, &tm
)
1177 || ((ltm
.tm_sec
^ tm
.tm_sec
)
1178 | (ltm
.tm_min
^ tm
.tm_min
)
1179 | (ltm
.tm_hour
^ tm
.tm_hour
)
1180 | (ltm
.tm_mday
^ tm
.tm_mday
)
1181 | (ltm
.tm_mon
^ tm
.tm_mon
)
1182 | (ltm
.tm_year
^ tm
.tm_year
)))
1186 if (! my_strftime_gmtime_r (<
, >m
))
1189 diff
= tm_diff (<m
, >m
);
1202 DO_NUMBER (4, (diff
/ 60) * 100 + diff
% 60);
1205 case '\0': /* GNU extension: % at end of format. */
1209 /* Unknown format; output the format, including the '%',
1210 since this is most likely the right thing to do if a
1211 multibyte string has been misparsed. */
1215 for (flen
= 1; f
[1 - flen
] != '%'; flen
++)
1217 cpy (flen
, &f
[1 - flen
]);
1223 if (p
&& maxsize
!= 0)
1230 /* For Emacs we have a separate interface which corresponds to the normal
1231 strftime function and does not have the extra information whether the
1232 TP arguments comes from a `gmtime' call or not. */
1234 emacs_strftime (s
, maxsize
, format
, tp
)
1238 const struct tm
*tp
;
1240 return my_strftime (s
, maxsize
, format
, tp
, 0);