comparison src/editfns.c @ 9812:bc352c8f079c

(Fdecode_time): Fix Lisp_Object vs. integer problems. Don't use tm_gmtoff; it's not portable.
author Karl Heuer <kwzh@gnu.org>
date Wed, 02 Nov 1994 04:27:27 +0000
parents bc6042c687a0
children 90784ed0416f
comparison
equal deleted inserted replaced
9811:c6270c781781 9812:bc352c8f079c
37 37
38 #define min(a, b) ((a) < (b) ? (a) : (b)) 38 #define min(a, b) ((a) < (b) ? (a) : (b))
39 #define max(a, b) ((a) > (b) ? (a) : (b)) 39 #define max(a, b) ((a) > (b) ? (a) : (b))
40 40
41 extern void insert_from_buffer (); 41 extern void insert_from_buffer ();
42 static long difftm ();
42 43
43 /* Some static data, and a function to initialize it for each run */ 44 /* Some static data, and a function to initialize it for each run */
44 45
45 Lisp_Object Vsystem_name; 46 Lisp_Object Vsystem_name;
46 Lisp_Object Vuser_real_name; /* login name of current user ID */ 47 Lisp_Object Vuser_real_name; /* login name of current user ID */
701 (Note that Common Lisp has different meanings for DOW and ZONE.)") 702 (Note that Common Lisp has different meanings for DOW and ZONE.)")
702 (specified_time) 703 (specified_time)
703 Lisp_Object specified_time; 704 Lisp_Object specified_time;
704 { 705 {
705 time_t time_spec; 706 time_t time_spec;
707 struct tm save_tm;
706 struct tm *decoded_time; 708 struct tm *decoded_time;
707 Lisp_Object list_args[9]; 709 Lisp_Object list_args[9];
708 710
709 if (! lisp_time_argument (specified_time, &time_spec)) 711 if (! lisp_time_argument (specified_time, &time_spec))
710 error ("Invalid time specification"); 712 error ("Invalid time specification");
711 713
712 decoded_time = localtime (&time_spec); 714 decoded_time = localtime (&time_spec);
713 list_args[0] = XFASTINT (decoded_time->tm_sec); 715 XSETFASTINT (list_args[0], decoded_time->tm_sec);
714 list_args[1] = XFASTINT (decoded_time->tm_min); 716 XSETFASTINT (list_args[1], decoded_time->tm_min);
715 list_args[2] = XFASTINT (decoded_time->tm_hour); 717 XSETFASTINT (list_args[2], decoded_time->tm_hour);
716 list_args[3] = XFASTINT (decoded_time->tm_mday); 718 XSETFASTINT (list_args[3], decoded_time->tm_mday);
717 list_args[4] = XFASTINT (decoded_time->tm_mon + 1); 719 XSETFASTINT (list_args[4], decoded_time->tm_mon + 1);
718 list_args[5] = XFASTINT (decoded_time->tm_year + 1900); 720 XSETFASTINT (list_args[5], decoded_time->tm_year + 1900);
719 list_args[6] = XFASTINT (decoded_time->tm_wday); 721 XSETFASTINT (list_args[6], decoded_time->tm_wday);
720 list_args[7] = (decoded_time->tm_isdst)? Qt : Qnil; 722 list_args[7] = (decoded_time->tm_isdst)? Qt : Qnil;
721 list_args[8] = XINT (decoded_time->tm_gmtoff); 723
724 /* Make a copy, in case gmtime modifies the struct. */
725 save_tm = *decoded_time;
726 decoded_time = gmtime (&time_spec);
727 if (decoded_time == 0)
728 list_args[8] = Qnil;
729 else
730 XSETINT (list_args[8], difftm (&save_tm, decoded_time));
722 return Flist (9, list_args); 731 return Flist (9, list_args);
723 } 732 }
724 733
725 DEFUN ("current-time-string", Fcurrent_time_string, Scurrent_time_string, 0, 1, 0, 734 DEFUN ("current-time-string", Fcurrent_time_string, Scurrent_time_string, 0, 1, 0,
726 "Return the current time, as a human-readable string.\n\ 735 "Return the current time, as a human-readable string.\n\