Emacs Lisp 的 strtotime
Emacs Lisp 中是否有任何功能与 PHP 的 strtotime
函数 类似? (实际上据我所知,它实现了 relative GNU 日期输入格式的项目。)
在 PHP 中,我可以编写
echo strtotime("+2 months"); //1258891352
echo strtotime("-3 months +2 weeks"); //1246952239
返回相应 UNIX 时间戳的代码。
Is there any functionality in Emacs Lisp that behaves similar to PHP's strtotime
function? (Actually AFAIK it implements relative items of the GNU date input formats.)
In PHP I can write
echo strtotime("+2 months"); //1258891352
echo strtotime("-3 months +2 weeks"); //1246952239
which return the corresponding UNIX timestamps.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
虽然不完全是您所要求的,但这可能有用。 org-mode 包中有一个命令
'org-schedule
,它有一个非常好的选择日期的界面。执行此操作的具体命令是'org-read-date
,它理解表示日期的多种方式,包括:如果您正在寻找一种交互式方式来使用方便的语法糖来指定日期,那么该例程应该非常适合您的要求。如果您正在寻找编程解决方案,上面的命令看起来就像调用
'org-read-date-analyze
来完成这项工作。注意:它的用法有点晦涩(它的两个参数从未定义过......),所以如果您无法直接弄清楚它,可能值得将邮件发送到 组织邮件列表。While not exactly what you're asking for, this may be of use. There's a command
'org-schedule
in the package org-mode that has a really nice interface to choosing dates. The specific command that does it is'org-read-date
, which understands many ways of representing the date, including:If you're looking for an interactive way to specify dates with that handy syntactic sugar, that routine should fit the bill nicely. If you're looking for a programmatic solution, it looks as though the above command calls
'org-read-date-analyze
to do the leg work. Note: its usage is a little obscure (two of its arguments are never defined...), so if you can't figure it out directly, it might be worth sending mail to the org mailing list.我所知道的最接近的内置函数是编码时间。如果你想使用自然语言,你可能不得不写这样的东西: http://github .com/chaitanyagupta/chronicity
The closest inbuilt function I know of is encode-time. If you want to use natural language, you'll probably have to end up writing something like this: http://github.com/chaitanyagupta/chronicity