From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Giorgos Keramidas Newsgroups: gmane.emacs.help Subject: Re: problem with time-stamps on GNU/Linux and Windows Date: Fri, 05 Sep 2008 03:38:12 +0300 Organization: SunSITE.dk - Supporting Open source Message-ID: <874p4vig0b.fsf@kobe.laptop> References: <48C01A64.9060705@mousecar.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1220575242 29949 80.91.229.12 (5 Sep 2008 00:40:42 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 5 Sep 2008 00:40:42 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Sep 05 02:41:37 2008 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 1KbPOL-0003qL-GP for geh-help-gnu-emacs@m.gmane.org; Fri, 05 Sep 2008 02:41:37 +0200 Original-Received: from localhost ([127.0.0.1]:36618 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KbPNM-0000qG-6g for geh-help-gnu-emacs@m.gmane.org; Thu, 04 Sep 2008 20:40:36 -0400 Original-Path: news.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!feeder.erje.net!newsfeed.straub-nv.de!news-out2.kabelfoon.nl!newsfeed.kabelfoon.nl!xindi.nntp.kabelfoon.nl!news.banetele.no!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (berkeley-unix) Cancel-Lock: sha1:oNkkDWX9VkA0N28mu81DqVKACUw= Original-Lines: 51 Original-NNTP-Posting-Host: 77.49.184.66 Original-X-Trace: news.sunsite.dk DXC=bf1; c1; Ra^NSi^`20K04QCYSB=nbEKnkKjL0kO3l6odNL^MjGbH?lJH1TkjLDlid?Xj:>EC3ACTffK=G[H Original-X-Complaints-To: staff@sunsite.dk Original-Xref: news.stanford.edu gnu.emacs.help:161944 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:57287 Archived-At: On Thu, 04 Sep 2008 20:37:26 +0200, Seweryn Kokot wrote: > Well, (current-time-string) function returns the same strings on both > systems, but in English, for example: "Thu Sep 4 20:16:51 2008". BTW > why this function gives abbreviations in English and not the locale's > ones? Because this way the output is predictably formatted, and programs can read it with a well-known, predefined format. The `format-time-string' function can be used for locale-aware results. > Whereas this function > > (defun my-insert-time-stamp () > (interactive) > (insert (format-time-string "%a %b %d %02H:%02M:%02S %Y"))) > > on Windows gives > (my-insert-time-stamp) > Cz wrz 04 20:13:20 2008 > > and on GNU/Linux: > czw wrz 04 20:16:29 2008 > > I raise this problem because org-mode has some problems parsing these > inconsistent abbreviations. > > Is it possible to get the result of (my-insert-time-stamp) in English > like in the case of the (current-time-string) function? One way to get predictable timestamps in `my-insert-time-stamp' is to temporarily alter the value of `system-time-locale': (defun my-insert-time-stamp () (interactive) (insert (let ((system-time-locale "C")) (format-time-string "%a %b %d %02H:%02M:%02S %Y")))) This will always use the "C" locale when displaying time, and the output inserted by `my-insert-time-stamp' will be similar to: "Fri Sep 05 03:34:47 2008" To make the timestamps inserted independent of the local timezone, it may also be worth to call `format-time-string' with a third argument of `T' to output the timestamp in UTC: (defun my-insert-time-stamp () (interactive) (insert (let ((system-time-locale "C")) (format-time-string "%a %b %d %02H:%02M:%02S %Y" (current-time) t))))