代码之家  ›  专栏  ›  技术社区  ›  viam0Zah

Emacs Lisp的strotime

  •  4
  • viam0Zah  · 技术社区  · 15 年前

    Emacs Lisp中是否有与以下功能类似的功能 PHP's strtotime function relative items of the GNU date input formats .)

    用PHP我可以写

    echo strtotime("+2 months"); //1258891352
    echo strtotime("-3 months +2 weeks"); //1246952239
    

    返回相应的UNIX时间戳。

    3 回复  |  直到 15 年前
        1
  •  4
  •   Trey Jackson    15 年前

    'org-schedule 包装中 org-mode '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.
    

    如果您正在寻找一种交互式的方法来指定日期,那么这个例程应该非常适合。如果您正在寻找一个编程解决方案,那么上面的命令似乎调用了 'org-read-date-analyze 做腿部运动。注意:它的用法有点晦涩难懂(它的两个参数从未定义过…),所以如果您不能直接理解它,那么向 org mailing list

        2
  •  3
  •   huaiyuan    15 年前
    (defun string-to-time (date)
      (shell-command-to-string (format "date --date='%s' +%%s" date)))
    
        3
  •  1
  •   artagnon    15 年前

    我所知道的最接近的内置函数是编码时间。如果你想使用自然语言,你可能不得不这样写: http://github.com/chaitanyagupta/chronicity