emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Bug: `org-timestamp-format' does not return correct time [8.2.10 (8.2.10-41-g42228a-elpa @ /home/gk/.emacs.d/packages/org-20150601/)]
@ 2015-10-21 16:42 Göktuğ Kayaalp
  2015-10-21 17:52 ` Kyle Meyer
  0 siblings, 1 reply; 3+ messages in thread
From: Göktuğ Kayaalp @ 2015-10-21 16:42 UTC (permalink / raw)
  To: emacs-orgmode


Remember to cover the basics, that is, what you expected to happen and
what in fact did happen.  You don't know how to make a good report?  See

     http://orgmode.org/manual/Feedback.html#Feedback

Your bug report will be posted to the Org-mode mailing list.
------------------------------------------------------------------------

The function `org-timestamp-format' returns bad values:

    (org-timestamp-format "<2015-10-07 Wed>" "%d %B %Y")
    "30 November -001"
    (org-timestamp-format "[2015-10-07 Wed]" "%d %B %Y")
    "30 November -001"
    (org-timestamp-format "[2015-10-07]" "%d %B %Y")
    "30 November -001"
    (org-timestamp-format "<2015-10-07>" "%d %B %Y")
    "30 November -001"
    (org-timestamp-format "2015-10-07" "%d %B %Y")
    "30 November -001"
    (org-timestamp-format (current-time) "%d %B %Y")
    "30 November -001"
    (org-timestamp-format (org-parse-time-string "[2015-10-07 Wed]")
                          "%d %B %Y")
    "30 November -001"


I tried this for my latex export filter, and got the same output for the
timestamp in the second example:

    (defun gk-ox-latex-format-inactive-timestamp (text backend info)
      (when (org-export-derived-backend-p backend 'latex)
        (org-timestamp-format text "%d %B %Y")))

I get the expected result from this piece of code:

    (format-time-string
     "%d %B %Y"
     (apply #'encode-time
            (org-parse-time-string
             text)))
    "07 November 2015"

I see two commits that affect this function, visible here:

http://orgmode.org/cgit.cgi/org-mode.git/log/?qt=grep&q=org-timestamp-format&showmsg=1

One of them adds it, the other one refactors it, without changing the logic.

Emacs  : GNU Emacs 24.5.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.16.6)
 of 2015-09-10 on foutrelis
Package: Org-mode version 8.2.10 (8.2.10-41-g42228a-elpa @ /home/gk/.emacs.d/packages/org-20150601/)

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

* Re: Bug: `org-timestamp-format' does not return correct time [8.2.10 (8.2.10-41-g42228a-elpa @ /home/gk/.emacs.d/packages/org-20150601/)]
  2015-10-21 16:42 Göktuğ Kayaalp
@ 2015-10-21 17:52 ` Kyle Meyer
  0 siblings, 0 replies; 3+ messages in thread
From: Kyle Meyer @ 2015-10-21 17:52 UTC (permalink / raw)
  To: Göktuğ Kayaalp; +Cc: emacs-orgmode

Göktuğ Kayaalp <self@gkayaalp.com> writes:

> The function `org-timestamp-format' returns bad values:
>
>     (org-timestamp-format "<2015-10-07 Wed>" "%d %B %Y")
>     "30 November -001"
>     (org-timestamp-format "[2015-10-07 Wed]" "%d %B %Y")
>     "30 November -001"
>     (org-timestamp-format "[2015-10-07]" "%d %B %Y")
>     "30 November -001"
>     (org-timestamp-format "<2015-10-07>" "%d %B %Y")
>     "30 November -001"
>     (org-timestamp-format "2015-10-07" "%d %B %Y")
>     "30 November -001"
>     (org-timestamp-format (current-time) "%d %B %Y")
>     "30 November -001"
>     (org-timestamp-format (org-parse-time-string "[2015-10-07 Wed]")
>                           "%d %B %Y")
>     "30 November -001"

I think this is because org-timestamp-format works with timestamp
objects, as returned by org-element-context, rather than strings.

-- 
Kyle

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

* Re: Bug: `org-timestamp-format' does not return correct time [8.2.10 (8.2.10-41-g42228a-elpa @ /home/gk/.emacs.d/packages/org-20150601/)]
       [not found] <8BB8B1B0-E16C-4D16-B7E6-C0602C687B4D@gmail.com>
@ 2015-11-12  5:57 ` Kyle Meyer
  0 siblings, 0 replies; 3+ messages in thread
From: Kyle Meyer @ 2015-11-12  5:57 UTC (permalink / raw)
  To: Yaniv Gilad; +Cc: emacs-orgmode

Hi Yaniv,

[You forgot to include the list.  Adding now.]

Yaniv Gilad <yanivdll@gmail.com> writes:

> I’m seeing the same issue:
>
>  (let ((properties (org-export-get-environment)))
>         (princ (json-encode 
>                 (list 
>                  :date (org-timestamp-format (car (plist-get properties :date)) "%Y-%m-%d")
>                  :author (substring-no-properties (car (plist-get properties :author)))
>                  :category (cdr (assoc "CATEGORY" org-file-properties))
>                  :post (org-export-as backend nil nil t)
>                  :title (substring-no-properties (car (plist-get properties :title))))))))))

org-timestamp-format takes an element, not a string.  See the two posts
below.

http://article.gmane.org/gmane.emacs.orgmode/102033
http://article.gmane.org/gmane.emacs.orgmode/102018

-- 
Kyle

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

end of thread, other threads:[~2015-11-12  5:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <8BB8B1B0-E16C-4D16-B7E6-C0602C687B4D@gmail.com>
2015-11-12  5:57 ` Bug: `org-timestamp-format' does not return correct time [8.2.10 (8.2.10-41-g42228a-elpa @ /home/gk/.emacs.d/packages/org-20150601/)] Kyle Meyer
2015-10-21 16:42 Göktuğ Kayaalp
2015-10-21 17:52 ` Kyle Meyer

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).