diff options
author | Richard M. Stallman <rms@gnu.org> | 1993-03-12 12:02:31 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 1993-03-12 12:02:31 +0000 |
commit | 2148f2b438344b34e639531584b1b6056d4e0a84 (patch) | |
tree | af5de0c13674bf284efe7df1bf49b44de7bf7ebb /src/editfns.c | |
parent | 933ff4729c2ba80f7dbee4b2aba359be7f69f5f6 (diff) | |
download | emacs-2148f2b438344b34e639531584b1b6056d4e0a84.tar.gz |
(Fcurrent_time_string): Optional arg specifies time.
Diffstat (limited to 'src/editfns.c')
-rw-r--r-- | src/editfns.c | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/src/editfns.c b/src/editfns.c index 0a30a400a6c..d936dc4cdb6 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -541,15 +541,40 @@ resolution finer than a second.") } -DEFUN ("current-time-string", Fcurrent_time_string, Scurrent_time_string, 0, 0, 0, +DEFUN ("current-time-string", Fcurrent_time_string, Scurrent_time_string, 0, 1, 0, "Return the current time, as a human-readable string.\n\ -Programs can use it too, since the number of columns in each field is fixed.\n\ -The format is `Sun Sep 16 01:03:52 1973'.") - () +Programs can use this function to decode a time,\n\ +since the number of columns in each field is fixed.\n\ +The format is `Sun Sep 16 01:03:52 1973'.\n\ +If an argument is given, it specifies a time to format\n\ +instead of 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'.") + (specified_time) + Lisp_Object specified_time; { - long current_time = time ((long *) 0); + long value; char buf[30]; - register char *tem = (char *) ctime (¤t_time); + register char *tem; + + if (NILP (specified_time)) + value = time ((long *) 0); + else + { + Lisp_Object high, low; + high = Fcar (specified_time); + CHECK_NUMBER (high, 0); + low = Fcdr (specified_time); + if (XTYPE (low) == Lisp_Cons) + low = Fcar (low); + CHECK_NUMBER (low, 0); + value = ((XINT (high) << 16) + (XINT (low) & 0xffff)); + } + + tem = (char *) ctime (&value); strncpy (buf, tem, 24); buf[24] = 0; |