tags:

views:

61

answers:

2

Hi, I understand emacs lisp is great for handling dates and times, but does it have a function to convert strings to internal representation of integers using formats like %Y, %m, %d, %H, %M, %S, and so on? And also, in the emacs reference manual, it says that times are lists of two or three integers, but is there a more formal specification or description? ~ Thanks ~

Edit: Thanks for the responses - but guess I was wondering if there was a function that does format-time-string in reverse (like parse-time-string but with structure specifications for the input string)?

Edit2: I guess the answer is that there is nothing built in... but a partial implementation has been implemented here.

+1  A: 

The time is returned by most time related functions as a list of three integers. The first has the most significant 16 bits of the seconds, while the second has the least significant 16 bits. The third integer gives the microsecond count.

The microsecond count is zero on systems that do not provide resolution finer than a second.

As for the rest of your question have a look at this section of the manual in case you missed it.

Bozhidar Batsov
+1  A: 
(defun encode-time-string (string)
  (apply #'encode-time (parse-time-string string)))

The internal representation may change; I think it'd be better to use the provided documented API (encode-time, decode-time, etc) to access it.

huaiyuan