From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Edward Newsgroups: gmane.emacs.help Subject: elisp Q: round & display time in 5-min. increments Date: Tue, 27 Nov 2007 16:01:57 -0800 (PST) Organization: http://groups.google.com Message-ID: <59c4e557-3273-4a7a-a773-a4da0260a084@i12g2000prf.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1196210520 20694 80.91.229.12 (28 Nov 2007 00:42:00 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 28 Nov 2007 00:42:00 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Nov 28 01:42:07 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IxB09-0001DM-AC for geh-help-gnu-emacs@m.gmane.org; Wed, 28 Nov 2007 01:42:05 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IxAzu-0006qE-3J for geh-help-gnu-emacs@m.gmane.org; Tue, 27 Nov 2007 19:41:50 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!i12g2000prf.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 34 Original-NNTP-Posting-Host: 143.182.124.4 Original-X-Trace: posting.google.com 1196208118 3277 127.0.0.1 (28 Nov 2007 00:01:58 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Wed, 28 Nov 2007 00:01:58 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: i12g2000prf.googlegroups.com; posting-host=143.182.124.4; posting-account=Ebm03goAAAB8zC3V0HH22-SboyfzeP0u User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; InfoPath.1; .NET CLR 2.0.50727),gzip(gfe),gzip(gfe) X-HTTP-Via: 1.0 chfwpr04.ch.intel.com:911 (squid/2.6.STABLE12) Content-Disposition: inline Original-Xref: shelby.stanford.edu gnu.emacs.help:154182 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:49606 Archived-At: Currently I'm using the following snippet to generate the time rounded to the nearest 5-min. increment: (concat (format-time-string "%H" (current-time)) ":" (int-to-string (* (round (string-to-number (format-time-string "%M" (current- time))) 5) 5)) " ") This works for most times, but it doesn't cover any edge conditions. For example, between the 55th minute and the end of the hour, it rounds to "60" and doesn't carry to the hour. Around the 5th minute, it generates "5", but it doesn't pad with a zero. Does anyone know of some pre-existing code in Emacs that does what I'm trying to do? Or failing that, does anyone have an elegant snippet of code that accomplishes this task while meeting these edge- conditions? I'm not worried about the midnight edge-condition, but if you know of code that does that too, so much the better. Thanks, Edward