all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: don provan <dprovan@comcast.net>
To: help-gnu-emacs@gnu.org
Subject: Re: Checking parameters
Date: Mon, 18 Jun 2007 10:27:26 -0700	[thread overview]
Message-ID: <uzm2xmav5.fsf@comcast.net> (raw)
In-Reply-To: mailman.2283.1182079099.32220.help-gnu-emacs@gnu.org

"Lennart Borgman (gmail)" <lennart.borgman@gmail.com> writes:

> And this is better:
>
> (defun get-hours(time)
>    (interactive "sHH:MM: ")
>    (let ((timelist (split-string time ":"))
>          (errmsg "Time format error"))
>      (save-match-data
>        (unless (string-match "\\`[0-9]+:[0-9]\\{2\\}\\'" time)
>          (error errmsg)))
>      (+
>       (string-to-number (nth 0 timelist))
>       (/
>        (string-to-number (nth 1 timelist))
>        60.0))))

Go all the way:

(defun get-hours(time)
   (interactive "sHH:MM: ")
   (save-match-data
     (unless (string-match "\\`\\([0-9]+\\):\\([0-9]\\{2\\}\\)\\'" time)
       (error "Time format error"))
     (+
      (string-to-number (match-string 1 time))
      (/
       (string-to-number (match-string 2 time))
       60.0))))

-don

  parent reply	other threads:[~2007-06-18 17:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-17 10:17 Checking parameters Cecil Westerhof
2007-06-17 10:55 ` Lennart Borgman (gmail)
2007-06-17 11:18   ` Lennart Borgman (gmail)
2007-06-17 15:28   ` Nikolaj Schumacher
     [not found]   ` <mailman.2283.1182079099.32220.help-gnu-emacs@gnu.org>
2007-06-17 18:01     ` Cecil Westerhof
2007-06-18 17:27     ` don provan [this message]
2007-06-17 13:18 ` Tim X
2007-06-17 18:08   ` Cecil Westerhof

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=uzm2xmav5.fsf@comcast.net \
    --to=dprovan@comcast.net \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.