-#ifdef EMACS_CURRENT_TIME_ZONE
- int offset, savings_flag;
- char standard[11];
- char savings[11];
-
- EMACS_CURRENT_TIME_ZONE (&offset, &savings_flag, standard, savings);
-
- return Fcons (make_number (offset),
- Fcons ((savings_flag ? Qt : Qnil),
- Fcons (build_string (standard),
- Fcons (build_string (savings),
- Qnil))));
-#else
- error
- ("current-time-zone has not been implemented on this operating system.");
+ int ay = a->tm_year + (TM_YEAR_ORIGIN - 1);
+ int by = b->tm_year + (TM_YEAR_ORIGIN - 1);
+ return
+ (
+ (
+ (
+ /* difference in day of year */
+ a->tm_yday - b->tm_yday
+ /* + intervening leap days */
+ + ((ay >> 2) - (by >> 2))
+ - (ay/100 - by/100)
+ + ((ay/100 >> 2) - (by/100 >> 2))
+ /* + difference in years * 365 */
+ + (long)(ay-by) * 365
+ )*24 + (a->tm_hour - b->tm_hour)
+ )*60 + (a->tm_min - b->tm_min)
+ )*60 + (a->tm_sec - b->tm_sec);
+}
+
+DEFUN ("current-time-zone", Fcurrent_time_zone, Scurrent_time_zone, 0, 1, 0,
+ "Return the offset and name for the local time zone.\n\
+This returns a list of the form (OFFSET NAME).\n\
+OFFSET is an integer number of seconds ahead of UTC (east of Greenwich).\n\
+ A negative value means west of Greenwich.\n\
+NAME is a string giving the name of the time zone.\n\
+If an argument is given, it specifies when the time zone offset is determined\n\
+instead of using the current time. The argument should have the form:\n\
+ (HIGH . LOW)\n\
+or the form:\n\
+ (HIGH LOW . IGNORED).\n\
+Thus, you can use times obtained from `current-time'\n\
+and from `file-attributes'.\n\
+\n\
+Some operating systems cannot provide all this information to Emacs;\n\
+in this case, `current-time-zone' returns a list containing nil for\n\
+the data it can't find.")
+ (specified_time)
+ Lisp_Object specified_time;
+{
+ time_t value;
+ struct tm *t;
+
+ if (lisp_time_argument (specified_time, &value)
+ && (t = gmtime (&value)) != 0)
+ {
+ struct tm gmt;
+ long offset;
+ char *s, buf[6];
+
+ gmt = *t; /* Make a copy, in case localtime modifies *t. */
+ t = localtime (&value);
+ offset = difftm (t, &gmt);
+ s = 0;
+#ifdef HAVE_TM_ZONE
+ if (t->tm_zone)
+ s = t->tm_zone;