/* Decode ZONE as a time zone specification. */
-static const char *
+static Lisp_Object
decode_time_zone (Lisp_Object zone)
{
- const char *tzstring = NULL;
-
if (EQ (zone, Qt))
- tzstring = "UTC0";
+ return build_string ("UTC0");
else if (STRINGP (zone))
- tzstring = SSDATA (zone);
+ return zone;
else if (INTEGERP (zone))
{
static char const tzbuf_format[] = "XXX%s%"pI"d:%02d:%02d";
EMACS_INT abszone = eabs (XINT (zone)), zone_hr = abszone / (60 * 60);
int zone_min = (abszone / 60) % 60, zone_sec = abszone % 60;
- sprintf (tzbuf, tzbuf_format, &"-"[XINT (zone) < 0],
- zone_hr, zone_min, zone_sec);
- tzstring = tzbuf;
+ return make_formatted_string (tzbuf, tzbuf_format, &"-"[XINT (zone) < 0],
+ zone_hr, zone_min, zone_sec);
}
else
xsignal2 (Qerror, build_string ("Invalid time zone specification"), zone);
- return tzstring;
}
DEFUN ("encode-time", Fencode_time, Sencode_time, 6, MANY, 0,
value = mktime (&tm);
else
{
- timezone_t tz = tzalloc (decode_time_zone (zone));
+ timezone_t tz = tzalloc (SSDATA (decode_time_zone (zone)));
value = mktime_z (tz, &tm);
tzfree (tz);
}
only the former. */)
(Lisp_Object tz)
{
- const char *tzstring = NILP (tz) ? initial_tz : decode_time_zone (tz);
+ const char *tzstring = NILP (tz) ? initial_tz : SSDATA (decode_time_zone (tz));
block_input ();
set_time_zone_rule (tzstring);