comparison src/editfns.c @ 2154:69c58e548ca5

(Fcurrent_time_string): Optional arg specifies time.
author Richard M. Stallman <rms@gnu.org>
date Fri, 12 Mar 1993 12:02:31 +0000
parents a358c97a23e4
children 5ab51b7300e4
comparison
equal deleted inserted replaced
2153:42ceb87b43a1 2154:69c58e548ca5
539 539
540 return Flist (3, result); 540 return Flist (3, result);
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 { 549 If an argument is given, it specifies a time to format\n\
550 long current_time = time ((long *) 0); 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;
558 {
559 long value;
551 char buf[30]; 560 char buf[30];
552 register char *tem = (char *) ctime (&current_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;
556 581
557 return build_string (buf); 582 return build_string (buf);