aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1994-11-01 08:50:20 +0000
committerRichard M. Stallman1994-11-01 08:50:20 +0000
commit4691c06db4f966b99fe312fb6495f3b27f076a26 (patch)
tree70e38b3eb755ec1bc94bcd85fa963f4b34705c84 /src
parentbc536d847736f466727453ca6aa7c07aef6fce46 (diff)
downloademacs-4691c06db4f966b99fe312fb6495f3b27f076a26.tar.gz
emacs-4691c06db4f966b99fe312fb6495f3b27f076a26.zip
(init_editfns): Get the username from the environment
variable USERNAME instead of USER. (Fdecode_time): New function. (syms_of_editfns): defsubr it.
Diffstat (limited to 'src')
-rw-r--r--src/editfns.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/editfns.c b/src/editfns.c
index 654c0da2713..31e4fcb4767 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -79,7 +79,11 @@ init_editfns ()
79 or the effective uid if those are unset. */ 79 or the effective uid if those are unset. */
80 user_name = (char *) getenv ("LOGNAME"); 80 user_name = (char *) getenv ("LOGNAME");
81 if (!user_name) 81 if (!user_name)
82#ifdef WINDOWSNT
83 user_name = (char *) getenv ("USERNAME"); /* it's USERNAME on NT */
84#else /* WINDOWSNT */
82 user_name = (char *) getenv ("USER"); 85 user_name = (char *) getenv ("USER");
86#endif /* WINDOWSNT */
83 if (!user_name) 87 if (!user_name)
84 { 88 {
85 pw = (struct passwd *) getpwuid (geteuid ()); 89 pw = (struct passwd *) getpwuid (geteuid ());
@@ -683,6 +687,41 @@ The number of options reflects the strftime(3) function.")
683 } 687 }
684} 688}
685 689
690DEFUN ("decode-time", Fdecode_time, Sdecode_time, 0, 1, 0,
691 "Decode a time value as (SEC MINUTE HOUR DAY MONTH YEAR DOW DST ZONE).\n\
692The optional SPECIFIED-TIME should be a list of (HIGH LOW . IGNORED)\n\
693or (HIGH . LOW), as from `current-time' and `file-attributes', or `nil'\n\
694to use the current time. The list has the following nine members:\n\
695SEC is an integer between 0 and 59. MINUTE is an integer between 0 and 59.\n\
696HOUR is an integer between 0 and 23. DAY is an integer between 1 and 31.\n\
697MONTH is an integer between 1 and 12. YEAR is an integer indicating the\n\
698four-digit year. DOW is the day of week, an integer between 0 and 6, where\n\
6990 is Sunday. DST is t if daylight savings time is effect, otherwise nil.\n\
700ZONE is an integer indicating the number of seconds east of Greenwich.\n\
701(Note that Common Lisp has different meanings for DOW and ZONE.)")
702 (specified_time)
703 Lisp_Object specified_time;
704{
705 time_t time_spec;
706 struct tm *decoded_time;
707 Lisp_Object list_args[9];
708
709 if (! lisp_time_argument (specified_time, &time_spec))
710 error ("Invalid time specification");
711
712 decoded_time = localtime (&time_spec);
713 list_args[0] = XFASTINT (decoded_time->tm_sec);
714 list_args[1] = XFASTINT (decoded_time->tm_min);
715 list_args[2] = XFASTINT (decoded_time->tm_hour);
716 list_args[3] = XFASTINT (decoded_time->tm_mday);
717 list_args[4] = XFASTINT (decoded_time->tm_mon + 1);
718 list_args[5] = XFASTINT (decoded_time->tm_year + 1900);
719 list_args[6] = XFASTINT (decoded_time->tm_wday);
720 list_args[7] = (decoded_time->tm_isdst)? Qt : Qnil;
721 list_args[8] = XFASTINT (decoded_time->tm_gmtoff);
722 return Flist (9, list_args);
723}
724
686DEFUN ("current-time-string", Fcurrent_time_string, Scurrent_time_string, 0, 1, 0, 725DEFUN ("current-time-string", Fcurrent_time_string, Scurrent_time_string, 0, 1, 0,
687 "Return the current time, as a human-readable string.\n\ 726 "Return the current time, as a human-readable string.\n\
688Programs can use this function to decode a time,\n\ 727Programs can use this function to decode a time,\n\
@@ -2159,6 +2198,7 @@ syms_of_editfns ()
2159 defsubr (&Semacs_pid); 2198 defsubr (&Semacs_pid);
2160 defsubr (&Scurrent_time); 2199 defsubr (&Scurrent_time);
2161 defsubr (&Sformat_time_string); 2200 defsubr (&Sformat_time_string);
2201 defsubr (&Sdecode_time);
2162 defsubr (&Scurrent_time_string); 2202 defsubr (&Scurrent_time_string);
2163 defsubr (&Scurrent_time_zone); 2203 defsubr (&Scurrent_time_zone);
2164 defsubr (&Ssystem_name); 2204 defsubr (&Ssystem_name);