* git-like parsing of date strings
@ 2023-03-27 14:00 John Yates
2023-03-27 14:05 ` Eli Zaretskii
0 siblings, 1 reply; 7+ messages in thread
From: John Yates @ 2023-03-27 14:00 UTC (permalink / raw)
To: Help Gnu Emacs mailing list
In elisp, how can I parse dates specified using git's approxidate syntax?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: git-like parsing of date strings
2023-03-27 14:00 git-like parsing of date strings John Yates
@ 2023-03-27 14:05 ` Eli Zaretskii
2023-03-27 15:43 ` John Yates
0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2023-03-27 14:05 UTC (permalink / raw)
To: help-gnu-emacs
> From: John Yates <john@yates-sheets.org>
> Date: Mon, 27 Mar 2023 10:00:33 -0400
>
> In elisp, how can I parse dates specified using git's approxidate syntax?
Try the functions in lisp/calendar/parse-time.el.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: git-like parsing of date strings
2023-03-27 14:05 ` Eli Zaretskii
@ 2023-03-27 15:43 ` John Yates
2023-03-27 16:01 ` Eli Zaretskii
0 siblings, 1 reply; 7+ messages in thread
From: John Yates @ 2023-03-27 15:43 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: help-gnu-emacs
On Mon, Mar 27, 2023 at 10:06 AM Eli Zaretskii <eliz@gnu.org> wrote:
>
> Try the functions in lisp/calendar/parse-time.el.
parse-time appears to handle only absolute dates.
I need support for relative dates (e.g. yesterday, 3 days ago, etc).
Maybe something like: https://github.com/thatguystone/approxidate
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: git-like parsing of date strings
2023-03-27 15:43 ` John Yates
@ 2023-03-27 16:01 ` Eli Zaretskii
2023-03-27 23:49 ` Tim Landscheidt
0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2023-03-27 16:01 UTC (permalink / raw)
To: help-gnu-emacs
> From: John Yates <john@yates-sheets.org>
> Date: Mon, 27 Mar 2023 11:43:40 -0400
> Cc: help-gnu-emacs@gnu.org
>
> On Mon, Mar 27, 2023 at 10:06 AM Eli Zaretskii <eliz@gnu.org> wrote:
> >
> > Try the functions in lisp/calendar/parse-time.el.
>
> parse-time appears to handle only absolute dates.
>
> I need support for relative dates (e.g. yesterday, 3 days ago, etc).
Your OP never said anything about relative dates.
I don't think something like that exists in Emacs.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: git-like parsing of date strings
2023-03-27 16:01 ` Eli Zaretskii
@ 2023-03-27 23:49 ` Tim Landscheidt
2023-03-28 11:04 ` John Yates
0 siblings, 1 reply; 7+ messages in thread
From: Tim Landscheidt @ 2023-03-27 23:49 UTC (permalink / raw)
To: help-gnu-emacs
Eli Zaretskii <eliz@gnu.org> wrote:
>> > Try the functions in lisp/calendar/parse-time.el.
>> parse-time appears to handle only absolute dates.
>> I need support for relative dates (e.g. yesterday, 3 days ago, etc).
> Your OP never said anything about relative dates.
> I don't think something like that exists in Emacs.
Relative dates can be parsed by org-read-date, but the syn-
tax is not very Git-like. (For the latter, one can always
resort to `git rev-parse --since='3 weeks 2 days ago'` and
then parse the output.)
Tim
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: git-like parsing of date strings
2023-03-27 23:49 ` Tim Landscheidt
@ 2023-03-28 11:04 ` John Yates
2023-03-28 13:31 ` Tim Landscheidt
0 siblings, 1 reply; 7+ messages in thread
From: John Yates @ 2023-03-28 11:04 UTC (permalink / raw)
To: Tim Landscheidt; +Cc: help-gnu-emacs
On Mon, Mar 27, 2023 at 7:50 PM Tim Landscheidt <tim@tim-landscheidt.de> wrote:
>
> Relative dates can be parsed by org-read-date, but the syn-
> tax is not very Git-like.
Do you know where I would find that parsing code?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: git-like parsing of date strings
2023-03-28 11:04 ` John Yates
@ 2023-03-28 13:31 ` Tim Landscheidt
0 siblings, 0 replies; 7+ messages in thread
From: Tim Landscheidt @ 2023-03-28 13:31 UTC (permalink / raw)
To: help-gnu-emacs
John Yates <john@yates-sheets.org> wrote:
>> Relative dates can be parsed by org-read-date, but the syn-
>> tax is not very Git-like.
> Do you know where I would find that parsing code?
Well, it is probably somewhere in org-read-date-analyze, but
I would just use org-read-date:
| ELISP> (format-time-string "%Y-%m-%d" (org-read-date nil t "-3w"))
| "2023-03-07"
| ELISP> (format-time-string "%Y-%m-%d" (org-read-date nil t "+2d"))
| "2023-03-30"
| ELISP>
Tim
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-03-28 13:31 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-27 14:00 git-like parsing of date strings John Yates
2023-03-27 14:05 ` Eli Zaretskii
2023-03-27 15:43 ` John Yates
2023-03-27 16:01 ` Eli Zaretskii
2023-03-27 23:49 ` Tim Landscheidt
2023-03-28 11:04 ` John Yates
2023-03-28 13:31 ` Tim Landscheidt
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.