diff options
| author | Richard M. Stallman | 1993-03-12 12:02:31 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1993-03-12 12:02:31 +0000 |
| commit | 2148f2b438344b34e639531584b1b6056d4e0a84 (patch) | |
| tree | af5de0c13674bf284efe7df1bf49b44de7bf7ebb /src | |
| parent | 933ff4729c2ba80f7dbee4b2aba359be7f69f5f6 (diff) | |
| download | emacs-2148f2b438344b34e639531584b1b6056d4e0a84.tar.gz emacs-2148f2b438344b34e639531584b1b6056d4e0a84.zip | |
(Fcurrent_time_string): Optional arg specifies time.
Diffstat (limited to 'src')
| -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.") | |||
| 541 | } | 541 | } |
| 542 | 542 | ||
| 543 | 543 | ||
| 544 | DEFUN ("current-time-string", Fcurrent_time_string, Scurrent_time_string, 0, 0, 0, | 544 | DEFUN ("current-time-string", Fcurrent_time_string, Scurrent_time_string, 0, 1, 0, |
| 545 | "Return the current time, as a human-readable string.\n\ | 545 | "Return the current time, as a human-readable string.\n\ |
| 546 | Programs can use it too, since the number of columns in each field is fixed.\n\ | 546 | Programs can use this function to decode a time,\n\ |
| 547 | The format is `Sun Sep 16 01:03:52 1973'.") | 547 | since the number of columns in each field is fixed.\n\ |
| 548 | () | 548 | The format is `Sun Sep 16 01:03:52 1973'.\n\ |
| 549 | If an argument is given, it specifies a time to format\n\ | ||
| 550 | instead of the current time. The argument should have the form:\n\ | ||
| 551 | (HIGH . LOW)\n\ | ||
| 552 | or the form:\n\ | ||
| 553 | (HIGH LOW . IGNORED).\n\ | ||
| 554 | Thus, you can use times obtained from `current-time'\n\ | ||
| 555 | and from `file-attributes'.") | ||
| 556 | (specified_time) | ||
| 557 | Lisp_Object specified_time; | ||
| 549 | { | 558 | { |
| 550 | long current_time = time ((long *) 0); | 559 | long value; |
| 551 | char buf[30]; | 560 | char buf[30]; |
| 552 | register char *tem = (char *) ctime (¤t_time); | 561 | register char *tem; |
| 562 | |||
| 563 | if (NILP (specified_time)) | ||
| 564 | value = time ((long *) 0); | ||
| 565 | else | ||
| 566 | { | ||
| 567 | Lisp_Object high, low; | ||
| 568 | high = Fcar (specified_time); | ||
| 569 | CHECK_NUMBER (high, 0); | ||
| 570 | low = Fcdr (specified_time); | ||
| 571 | if (XTYPE (low) == Lisp_Cons) | ||
| 572 | low = Fcar (low); | ||
| 573 | CHECK_NUMBER (low, 0); | ||
| 574 | value = ((XINT (high) << 16) + (XINT (low) & 0xffff)); | ||
| 575 | } | ||
| 576 | |||
| 577 | tem = (char *) ctime (&value); | ||
| 553 | 578 | ||
| 554 | strncpy (buf, tem, 24); | 579 | strncpy (buf, tem, 24); |
| 555 | buf[24] = 0; | 580 | buf[24] = 0; |