有没有类似于 PHP 中的 strtotime
函数的 Emacs Lisp 功能?(实际上,据我所知它实现了 GNU 日期输入格式的相关项。)
在 PHP 中,我可以这样写:
echo strtotime("+2 months"); //1258891352
echo strtotime("-3 months +2 weeks"); //1246952239
返回相应的UNIX时间戳。
'org-schedule
,它具有非常好的选择日期界面。特定的命令是'org-read-date
,它可以理解许多表示日期的方式,包括: +0 --> today
. --> today
+4d --> four days from today
+4 --> same as above
+2w --> two weeks from today
++5 --> five days from default date
+2tue --> second Tuesday from now.
(defun string-to-time (date)
(shell-command-to-string (format "date --date='%s' +%%s" date)))
我所知道的最接近内置函数是encode-time。如果你想使用自然语言,你可能最终需要编写类似于这样的代码:http://github.com/chaitanyagupta/chronicity
org-read-date-analyze
不是一个命令,而是在org.el文件中的第13155行定义的(最新的org.el文件:http://repo.or.cz/w/org-mode.git/blob/HEAD:/lisp/org.el)。 - Trey Jacksonstrtotime
提供的功能,但其目标相似且是一种本地解决方案。 - viam0Zah