Mercurial > emacs
comparison src/editfns.c @ 15180:9a22c72359c1
(Fencode_time): Accept MANY args, so as to cope
with the value of decode-time.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 07 May 1996 18:55:40 +0000 |
parents | e8613675066c |
children | 9304a470dd2d |
comparison
equal
deleted
inserted
replaced
15179:be7cc250142a | 15180:9a22c72359c1 |
---|---|
706 else | 706 else |
707 XSETINT (list_args[8], difftm (&save_tm, decoded_time)); | 707 XSETINT (list_args[8], difftm (&save_tm, decoded_time)); |
708 return Flist (9, list_args); | 708 return Flist (9, list_args); |
709 } | 709 } |
710 | 710 |
711 DEFUN ("encode-time", Fencode_time, Sencode_time, 6, 7, 0, | 711 DEFUN ("encode-time", Fencode_time, Sencode_time, 6, MANY, 0, |
712 "Convert SECOND, MINUTE, HOUR, DAY, MONTH, YEAR and ZONE to internal time.\n\ | 712 "Convert SECOND, MINUTE, HOUR, DAY, MONTH, YEAR and ZONE to internal time.\n\ |
713 This is the reverse operation of `decode-time', which see. ZONE defaults\n\ | 713 This is the reverse operation of `decode-time', which see.\n\ |
714 to the current time zone rule if not specified; if specified, it can\n\ | 714 ZONE defaults to the current time zone rule. This can\n\ |
715 be a string (as from `set-time-zone-rule'), or it can be a list\n\ | 715 be a string (as from `set-time-zone-rule'), or it can be a list\n\ |
716 (as from `current-time-zone') or an integer (as from `decode-time')\n\ | 716 (as from `current-time-zone') or an integer (as from `decode-time')\n\ |
717 applied without consideration for daylight savings time.\n\ | 717 applied without consideration for daylight savings time.\n\ |
718 \n\ | |
719 You can pass more than 7 arguments; then the first six arguments\n\ | |
720 are used as SECOND through YEAR, and the *last* argument is used as ZONE.\n\ | |
721 The intervening arguments are ignored.\n\ | |
722 This feature lets (apply 'encode-time (decode-time ...)) work.\n\ | |
723 \n\ | |
718 Out-of-range values for SEC, MINUTE, HOUR, DAY, or MONTH are allowed;\n\ | 724 Out-of-range values for SEC, MINUTE, HOUR, DAY, or MONTH are allowed;\n\ |
719 for example, a DAY of 0 means the day preceding the given month.\n\ | 725 for example, a DAY of 0 means the day preceding the given month.\n\ |
720 Year numbers less than 100 are treated just like other year numbers.\n\ | 726 Year numbers less than 100 are treated just like other year numbers.\n\ |
721 If you want them to stand for years in this century, you must do that yourself.") | 727 If you want them to stand for years in this century, you must do that yourself.") |
722 (second, minute, hour, day, month, year, zone) | 728 (nargs, args) |
723 Lisp_Object second, minute, hour, day, month, year, zone; | 729 int nargs; |
730 register Lisp_Object *args; | |
724 { | 731 { |
725 time_t time; | 732 time_t time; |
726 struct tm tm; | 733 struct tm tm; |
727 | 734 Lisp_Object zone = (nargs > 6)? args[nargs - 1] : Qnil; |
728 CHECK_NUMBER (second, 0); | 735 |
729 CHECK_NUMBER (minute, 1); | 736 CHECK_NUMBER (args[0], 0); /* second */ |
730 CHECK_NUMBER (hour, 2); | 737 CHECK_NUMBER (args[1], 1); /* minute */ |
731 CHECK_NUMBER (day, 3); | 738 CHECK_NUMBER (args[2], 2); /* hour */ |
732 CHECK_NUMBER (month, 4); | 739 CHECK_NUMBER (args[3], 3); /* day */ |
733 CHECK_NUMBER (year, 5); | 740 CHECK_NUMBER (args[4], 4); /* month */ |
734 | 741 CHECK_NUMBER (args[5], 5); /* year */ |
735 tm.tm_sec = XINT (second); | 742 |
736 tm.tm_min = XINT (minute); | 743 tm.tm_sec = XINT (args[0]); |
737 tm.tm_hour = XINT (hour); | 744 tm.tm_min = XINT (args[1]); |
738 tm.tm_mday = XINT (day); | 745 tm.tm_hour = XINT (args[2]); |
739 tm.tm_mon = XINT (month) - 1; | 746 tm.tm_mday = XINT (args[3]); |
740 tm.tm_year = XINT (year) - 1900; | 747 tm.tm_mon = XINT (args[4]) - 1; |
748 tm.tm_year = XINT (args[5]) - 1900; | |
741 tm.tm_isdst = -1; | 749 tm.tm_isdst = -1; |
742 | 750 |
743 if (CONSP (zone)) | 751 if (CONSP (zone)) |
744 zone = Fcar (zone); | 752 zone = Fcar (zone); |
745 if (NILP (zone)) | 753 if (NILP (zone)) |