help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: current-time-zone


From: Kevin Rodgers
Subject: Re: current-time-zone
Date: Mon, 22 Dec 2003 12:12:36 -0700
User-agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:0.9.4.1) Gecko/20020406 Netscape6/6.2.2

Jesper Harder wrote:

gebser@speakeasy.net writes:
Should "M-x current-time-zone" return something?  Using emacs v.20.7.1
all get in the minibuffer is "[No match]".


`current-time-zone' is not an interactive function.  You can't call it
with `M-x'.

But you can if you do this:


(defadvice current-time-zone (around interactive activate)
  "If called interactively, display the result in the echo area (and
append to the *Messages* buffer).  If a prefix arg is specified, prompt
for SPECIFIED-TIME."
  (interactive (list (if current-prefix-arg
                         (let ((now (decode-time (current-time))))
                           (encode-time (string-to-number
                                         (read-string "Year: "
                                                      (format "%d"
                                                              (nth 5 now))))
                                        (string-to-number
                                         (read-string "Month: "
                                                      (format "%d"
                                                              (nth 4 now))))
                                        (string-to-number
                                         (read-string "Day: "
                                                      (format "%d"
                                                              (nth 3 now))))
                                        (string-to-number
                                         (read-string "Hour: "
                                                      (format "%d"
                                                              (nth 2 now))))
                                        (string-to-number
                                         (read-string "Minutes: "
                                                      (format "%d"
                                                              (nth 1 now))))
                                        (string-to-number
                                         (read-string "Seconds: "
                                                      (format "%d"
                                                              (nth 0 
now)))))))))
  ad-do-it
  (if (interactive-p)
      (message "%s" ad-return-value)
    ad-return-value))

--
Kevin Rodgers



reply via email to

[Prev in Thread] Current Thread [Next in Thread]