comparison src/editfns.c @ 5685:aa5f38ecb804

Accept GNU's UNIVERSAL argument to #'format-time-string. src/ChangeLog addition: 2012-09-16 Aidan Kehoe <kehoea@parhasard.net> * editfns.c (Fformat_time_string): Accept GNU's UNIVERSAL argument, which means we call gmtime() instead of localtime(). Thanks for the report of org-mode incompatibility, Matsl!
author Aidan Kehoe <kehoea@parhasard.net>
date Sun, 16 Sep 2012 21:43:21 +0100
parents 56144c8593a8
children 427a72c6ee17
comparison
equal deleted inserted replaced
5684:0eb4e96fd261 5685:aa5f38ecb804
996 size_t emacs_strftime (Extbyte *string, size_t max, const Extbyte *format, 996 size_t emacs_strftime (Extbyte *string, size_t max, const Extbyte *format,
997 const struct tm *tm); 997 const struct tm *tm);
998 static long difftm (const struct tm *a, const struct tm *b); 998 static long difftm (const struct tm *a, const struct tm *b);
999 999
1000 1000
1001 DEFUN ("format-time-string", Fformat_time_string, 1, 2, 0, /* 1001 DEFUN ("format-time-string", Fformat_time_string, 1, 3, 0, /*
1002 Use FORMAT-STRING to format the time TIME. 1002 Use FORMAT-STRING to format the time TIME.
1003 TIME is specified as (HIGH LOW . IGNORED) or (HIGH . LOW), as from 1003 TIME is specified as (HIGH LOW . IGNORED) or (HIGH . LOW), as from
1004 `current-time' and `file-attributes'. If TIME is not specified it 1004 `current-time' and `file-attributes'. If TIME is not specified it
1005 defaults to the current time. 1005 defaults to the current time.
1006 The third, optional, argument UNIVERSAL, if non-nil, means describe TIME
1007 as Universal Time; nil means describe TIME in the local time zone.
1006 FORMAT-STRING may contain %-sequences to substitute parts of the time. 1008 FORMAT-STRING may contain %-sequences to substitute parts of the time.
1007 %a is replaced by the abbreviated name of the day of week. 1009 %a is replaced by the abbreviated name of the day of week.
1008 %A is replaced by the full name of the day of week. 1010 %A is replaced by the full name of the day of week.
1009 %b is replaced by the abbreviated name of the month. 1011 %b is replaced by the abbreviated name of the month.
1010 %B is replaced by the full name of the month. 1012 %B is replaced by the full name of the month.
1045 %\\xe6 is replaced by the month as a lowercase Roman number (i-xii) 1047 %\\xe6 is replaced by the month as a lowercase Roman number (i-xii)
1046 %\\xc6 is replaced by the month as an uppercase Roman number (I-XII) 1048 %\\xc6 is replaced by the month as an uppercase Roman number (I-XII)
1047 1049
1048 The number of options reflects the `strftime' function. 1050 The number of options reflects the `strftime' function.
1049 */ 1051 */
1050 (format_string, time_)) 1052 (format_string, time_, universal))
1051 { 1053 {
1052 time_t value; 1054 time_t value;
1053 Bytecount size; 1055 Bytecount size;
1054 1056
1055 CHECK_STRING (format_string); 1057 CHECK_STRING (format_string);
1063 while (1) 1065 while (1)
1064 { 1066 {
1065 Extbyte *buf = alloca_extbytes (size); 1067 Extbyte *buf = alloca_extbytes (size);
1066 Extbyte *formext; 1068 Extbyte *formext;
1067 /* make a copy of the static buffer returned by localtime() */ 1069 /* make a copy of the static buffer returned by localtime() */
1068 struct tm tm = *localtime (&value); 1070 struct tm tm = NILP (universal) ? *localtime (&value) : *gmtime (&value);
1069 1071
1070 *buf = 1; 1072 *buf = 1;
1071 1073
1072 /* !!#### this use of external here is not totally safe, and 1074 /* !!#### this use of external here is not totally safe, and
1073 potentially data lossy. */ 1075 potentially data lossy. */