2011-03-11 Paul Eggert <eggert@cs.ucla.edu>
+ * editfns.c (time_overflow): New function, refactoring common code.
+ (Fformat_time_string, Fdecode_time, Fencode_time):
+ (Fcurrent_time_string): Use it.
+
Move 'make_time' to be next to its inverse 'lisp_time_argument'.
* dired.c (make_time): Move to ...
* editfns.c (make_time): ... here.
extern Lisp_Object w32_get_internal_run_time (void);
#endif
+static void time_overflow (void) NO_RETURN;
static int tm_diff (struct tm *, struct tm *);
static void find_field (Lisp_Object, Lisp_Object, Lisp_Object,
EMACS_INT *, Lisp_Object, EMACS_INT *);
}
\f
+/* Report a time value that is out of range for Emacs. */
+static void
+time_overflow (void)
+{
+ error ("Specified time is not representable");
+}
+
/* Make a Lisp list that represents the time T. */
Lisp_Object
make_time (time_t t)
tm = ut ? gmtime (&value) : localtime (&value);
UNBLOCK_INPUT;
if (! tm)
- error ("Specified time is not representable");
+ time_overflow ();
synchronize_system_time_locale ();
decoded_time = localtime (&time_spec);
UNBLOCK_INPUT;
if (! decoded_time)
- error ("Specified time is not representable");
+ time_overflow ();
XSETFASTINT (list_args[0], decoded_time->tm_sec);
XSETFASTINT (list_args[1], decoded_time->tm_min);
XSETFASTINT (list_args[2], decoded_time->tm_hour);
}
if (time == (time_t) -1)
- error ("Specified time is not representable");
+ time_overflow ();
return make_time (time);
}
tm = localtime (&value);
UNBLOCK_INPUT;
if (! (tm && TM_YEAR_IN_ASCTIME_RANGE (tm->tm_year) && (tem = asctime (tm))))
- error ("Specified time is not representable");
+ time_overflow ();
/* Remove the trailing newline. */
tem[strlen (tem) - 1] = '\0';