emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Format for timestamp export
@ 2009-04-06 23:12 Daniel Clemente
  2009-04-09  7:37 ` Carsten Dominik
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Clemente @ 2009-04-06 23:12 UTC (permalink / raw)
  To: mailing-list-org-mode


Hi. Since I edit my files from different computers, each with different locales, I end up with dates like:


    CLOCK: [2009-04-01 mié 14:15]--[2009-04-01 mié 14:22] =>  0:07
…
      SCHEDULED: <2009-03-26 dj 18:00>
…
  CLOSED: [2007-11-25 So 19:05]

… <2007-08-31 Fri 17:25>


  Emacs and I can live with these localised week day names, but to external (HTML) users I would like to show dates in a custom format so that they always look the same.


  Can I format timestamps on export?


Thanks,
Daniel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Format for timestamp export
  2009-04-06 23:12 Format for timestamp export Daniel Clemente
@ 2009-04-09  7:37 ` Carsten Dominik
  2009-04-12 18:37   ` Daniel Clemente
  0 siblings, 1 reply; 6+ messages in thread
From: Carsten Dominik @ 2009-04-09  7:37 UTC (permalink / raw)
  To: Daniel Clemente; +Cc: mailing-list-org-mode


On Apr 7, 2009, at 1:12 AM, Daniel Clemente wrote:

>
> Hi. Since I edit my files from different computers, each with  
> different locales, I end up with dates like:
>
>
>   CLOCK: [2009-04-01 mié 14:15]--[2009-04-01 mié 14:22] =>  0:07
> …
>     SCHEDULED: <2009-03-26 dj 18:00>
> …
> CLOSED: [2007-11-25 So 19:05]
>
> … <2007-08-31 Fri 17:25>
>
>
> Emacs and I can live with these localised week day names, but to  
> external (HTML) users I would like to show dates in a custom format  
> so that they always look the same.
>
>
> Can I format timestamps on export?

You can customize them for display, which will also
transfer to exported files.
Check out the variables `org-display-custom-times' and
`org-time-stamp-custom-formats'.

When you turn this on, you lose some of the editing capabilities
for time stamps with S-cursor keys.  So if you really only need it
for export, you can use one of the export preprocessor hooks and
change all the time stamps with a function like (untested):

(add-hook 'org-export-preprocess-final-hook
  (lambda ()
    (let ((org-display-custom-times t)
	  (org-time-stamp-custom-formats
	   '("<%m/%d/%y %a>" . "<%m/%d/%y %a %H:%M>"))) ;; customize!
      (goto-char (point-min))
      (while (re-search-forward org-ts-regexp-both nil t)
	(replace-match (save-match-data
			 (org-translate-time (match-string 0)))
		       t t)))))

HTH

- Carsten






>
>
> Thanks,
> Daniel
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Format for timestamp export
  2009-04-09  7:37 ` Carsten Dominik
@ 2009-04-12 18:37   ` Daniel Clemente
  2009-04-12 18:43     ` Christopher Suckling
  2009-04-13  6:54     ` Carsten Dominik
  0 siblings, 2 replies; 6+ messages in thread
From: Daniel Clemente @ 2009-04-12 18:37 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: mailing-list-org-mode

El jue, abr 09 2009, Carsten Dominik va escriure:
>>
>> Can I format timestamps on export?
>
> You can customize them for display, which will also
> transfer to exported files.
> Check out the variables `org-display-custom-times' and
> `org-time-stamp-custom-formats'.
>
  Thanks; I didn't know that org-display-custom-times would affect also the export. Could the documentation say that?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Format for timestamp export
  2009-04-12 18:37   ` Daniel Clemente
@ 2009-04-12 18:43     ` Christopher Suckling
  2009-04-13  6:54     ` Carsten Dominik
  1 sibling, 0 replies; 6+ messages in thread
From: Christopher Suckling @ 2009-04-12 18:43 UTC (permalink / raw)
  To: Daniel Clemente; +Cc: mailing-list-org-mode

[-- Attachment #1: Type: text/plain, Size: 852 bytes --]


On 12 Apr 2009, at 19:37, Daniel Clemente wrote:

> El jue, abr 09 2009, Carsten Dominik va escriure:
>>>
>>> Can I format timestamps on export?
>>
>> You can customize them for display, which will also
>> transfer to exported files.
>> Check out the variables `org-display-custom-times' and
>> `org-time-stamp-custom-formats'.
>>
>  Thanks; I didn't know that org-display-custom-times would affect  
> also the export. Could the documentation say that?
>

BTW, this doesn't work in the latex exporter. I used the attached ugly  
hack rather than fix the latex exporter - I suspect I was in a rush to  
get a piece of work out to someone. Anyway, the function cas/org- 
export-as-latex-to-buffer-with-timestamp behaves the same as org- 
export-as-latex-to-buffer, but translates all timestamps to org-time- 
stamp-custom-formats.

Best,

Christopher


[-- Attachment #2: org-latex-timestamp.el --]
[-- Type: application/octet-stream, Size: 2237 bytes --]

;; org-mode export as LaTeX with timestamp translation.
;; Author: Christopher Suckling
;;  An ugly hack to preprocess timestamp translation for latex
;; export. All timestamps are converted to the format held by
;; org-time-stamp-custom-formats.

(defun cas/org-translate-time (string)
  "Translate all timestamps in STRING to custom format."
  (save-match-data
    (let* ((start 0)
	   (re org-ts-regexp-both)
	   t1 with-hm inactive tf time str beg end)
      (while (setq start (string-match re string start))
	(setq beg (match-beginning 0)
	      end (match-end 0)
	      t1 (save-match-data
		   (org-parse-time-string (substring string beg end) t))
	      with-hm (and (nth 1 t1) (nth 2 t1))
	      inactive (equal (substring string beg (1+ beg)) "[")
	      tf (funcall (if with-hm 'cdr 'car)
			  org-time-stamp-custom-formats)
	      time (org-fix-decoded-time t1)
	      str (format-time-string
		   (concat
		    (if inactive "[" "<") (substring tf 1 -1)
		    (if inactive "]" ">"))
		   (apply 'encode-time time))
	      string (replace-match str t t string)
	      start (+ start (length str))))));)
   (prin1 string))

(defun cas/delete-export-files (list)
  (while list
    (delete-file (car list))
    (setq list (cdr list))))

(defun cas/org-export-as-latex-to-buffer-with-timestamp ()
  "Ugly hack;; behaves as org-export-as-latex-to-buffer, but translates all timestamps to org-time-stamp-custom-formats"
  (interactive)
  (with-output-to-temp-buffer "*org-export*"
    (cas/org-translate-time (buffer-substring-no-properties (mark) (point))))
  (switch-to-buffer "*org-export*")
  (delete-other-windows)
  (org-mode)
  (goto-char (point-min))
  (save-excursion
    (while 
	(re-search-forward "[]\\[]" nil t)
      (replace-match "")))
  (save-excursion
    (while
	(re-search-forward "\"" nil t)
      (replace-match "")))
  (write-file org-directory)
  (org-export-as-latex org-export-headline-levels nil nil "*Org LaTeX Export*")
  (set-buffer-modified-p nil)
  (kill-buffer "*org-export*")
  (switch-to-buffer-other-window "*Org LaTeX Export*")
  (latex-mode)
  (setq tempExportFiles (directory-files org-directory 1 "*org-export*"))
  (cas/delete-export-files tempExportFiles))

(provide 'org-latex-timestamp)

[-- Attachment #3: Type: text/plain, Size: 1 bytes --]



[-- Attachment #4: Type: text/plain, Size: 204 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Format for timestamp export
  2009-04-12 18:37   ` Daniel Clemente
  2009-04-12 18:43     ` Christopher Suckling
@ 2009-04-13  6:54     ` Carsten Dominik
  2009-04-13  8:50       ` Christopher Suckling
  1 sibling, 1 reply; 6+ messages in thread
From: Carsten Dominik @ 2009-04-13  6:54 UTC (permalink / raw)
  To: Daniel Clemente; +Cc: mailing-list-org-mode

Fixed for LaTeX export, and documented.

- Carsten

On Apr 12, 2009, at 8:37 PM, Daniel Clemente wrote:

> El jue, abr 09 2009, Carsten Dominik va escriure:
>>>
>>> Can I format timestamps on export?
>>
>> You can customize them for display, which will also
>> transfer to exported files.
>> Check out the variables `org-display-custom-times' and
>> `org-time-stamp-custom-formats'.
>>
>  Thanks; I didn't know that org-display-custom-times would affect  
> also the export. Could the documentation say that?
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Format for timestamp export
  2009-04-13  6:54     ` Carsten Dominik
@ 2009-04-13  8:50       ` Christopher Suckling
  0 siblings, 0 replies; 6+ messages in thread
From: Christopher Suckling @ 2009-04-13  8:50 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: mailing-list-org-mode emacs-orgmode


On 13 Apr 2009, at 07:54, Carsten Dominik wrote:

> Fixed for LaTeX export, and documented.
>
> - Carsten

Thanks. Works perfectly.

Christopher

>
> On Apr 12, 2009, at 8:37 PM, Daniel Clemente wrote:
>
>> El jue, abr 09 2009, Carsten Dominik va escriure:
>>>>
>>>> Can I format timestamps on export?
>>>
>>> You can customize them for display, which will also
>>> transfer to exported files.
>>> Check out the variables `org-display-custom-times' and
>>> `org-time-stamp-custom-formats'.
>>>
>> Thanks; I didn't know that org-display-custom-times would affect  
>> also the export. Could the documentation say that?
>>
>
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-04-13  8:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-06 23:12 Format for timestamp export Daniel Clemente
2009-04-09  7:37 ` Carsten Dominik
2009-04-12 18:37   ` Daniel Clemente
2009-04-12 18:43     ` Christopher Suckling
2009-04-13  6:54     ` Carsten Dominik
2009-04-13  8:50       ` Christopher Suckling

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).