comparison src/editfns.c @ 4203:0a63e5de7bdc

[xemacs-hg @ 2007-10-02 19:31:30 by aidan] Synch up format-time-string % specifiers with Emacs 21.3.1, from Shyamal Prasad.
author aidan
date Tue, 02 Oct 2007 19:31:31 +0000
parents b95fe16005fd
children c5a2b80bc4fa
comparison
equal deleted inserted replaced
4202:a7c5de5b9880 4203:0a63e5de7bdc
1013 %c is a synonym for "%x %X". 1013 %c is a synonym for "%x %X".
1014 %C is a locale-specific synonym, which defaults to "%A, %B %e, %Y" in the C locale. 1014 %C is a locale-specific synonym, which defaults to "%A, %B %e, %Y" in the C locale.
1015 %d is replaced by the day of month, zero-padded. 1015 %d is replaced by the day of month, zero-padded.
1016 %D is a synonym for "%m/%d/%y". 1016 %D is a synonym for "%m/%d/%y".
1017 %e is replaced by the day of month, blank-padded. 1017 %e is replaced by the day of month, blank-padded.
1018 %G is replaced by the year containing the ISO 8601 week
1019 %g is replaced by the year of the ISO 8601 week within the century (00-99)
1018 %h is a synonym for "%b". 1020 %h is a synonym for "%b".
1019 %H is replaced by the hour (00-23). 1021 %H is replaced by the hour (00-23).
1020 %I is replaced by the hour (00-12). 1022 %I is replaced by the hour (00-12).
1021 %j is replaced by the day of the year (001-366). 1023 %j is replaced by the day of the year (001-366).
1022 %k is replaced by the hour (0-23), blank padded. 1024 %k is replaced by the hour (0-23), blank padded.
1031 nonstandard extension) 1033 nonstandard extension)
1032 %S is replaced by the second (00-60). 1034 %S is replaced by the second (00-60).
1033 %t is a synonym for "\\t". 1035 %t is a synonym for "\\t".
1034 %T is a synonym for "%H:%M:%S". 1036 %T is a synonym for "%H:%M:%S".
1035 %U is replaced by the week of the year (00-53), first day of week is Sunday. 1037 %U is replaced by the week of the year (00-53), first day of week is Sunday.
1038 %V is replaced by the ISO 8601 week number
1036 %w is replaced by the day of week (0-6), Sunday is day 0. 1039 %w is replaced by the day of week (0-6), Sunday is day 0.
1037 %W is replaced by the week of the year (00-53), first day of week is Monday. 1040 %W is replaced by the week of the year (00-53), first day of week is Monday.
1038 %x is a locale-specific synonym, which defaults to "%D" in the C locale. 1041 %x is a locale-specific synonym, which defaults to "%D" in the C locale.
1039 %X is a locale-specific synonym, which defaults to "%T" in the C locale. 1042 %X is a locale-specific synonym, which defaults to "%T" in the C locale.
1040 %y is replaced by the year without century (00-99). 1043 %y is replaced by the year without century (00-99).
1041 %Y is replaced by the year with century. 1044 %Y is replaced by the year with century.
1045 %z is replaced by the time zone as a numeric offset (e.g +0530, -0800 etc.)
1042 %Z is replaced by the time zone abbreviation. 1046 %Z is replaced by the time zone abbreviation.
1043 1047
1044 The number of options reflects the `strftime' function. 1048 The number of options reflects the `strftime' function.
1045 1049
1046 BUG: If the charset used by the current locale is not ISO 8859-1, the 1050 BUG: If the charset used by the current locale is not ISO 8859-1, the
1061 1065
1062 while (1) 1066 while (1)
1063 { 1067 {
1064 Extbyte *buf = alloca_extbytes (size); 1068 Extbyte *buf = alloca_extbytes (size);
1065 Extbyte *formext; 1069 Extbyte *formext;
1070 /* make a copy of the static buffer returned by localtime() */
1071 struct tm tm = * localtime(&value);
1072
1066 *buf = 1; 1073 *buf = 1;
1067 1074
1068 /* !!#### this use of external here is not totally safe, and 1075 /* !!#### this use of external here is not totally safe, and
1069 potentially data lossy. */ 1076 potentially data lossy. */
1070 LISP_STRING_TO_EXTERNAL (format_string, formext, Qnative); 1077 LISP_STRING_TO_EXTERNAL (format_string, formext, Qnative);
1071 if (emacs_strftime (buf, size, formext, 1078 if (emacs_strftime (buf, size, formext, &tm)
1072 localtime (&value))
1073 || !*buf) 1079 || !*buf)
1074 return build_ext_string (buf, Qnative); 1080 return build_ext_string (buf, Qnative);
1075 /* If buffer was too small, make it bigger. */ 1081 /* If buffer was too small, make it bigger. */
1076 size *= 2; 1082 size *= 2;
1077 } 1083 }