-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdate-utils.el
44 lines (40 loc) · 1.4 KB
/
date-utils.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
;;; date-utils.el just for test
;; 解析这种格式的日期字符串 Sun, 19 Jun 2016 03:02:30 GMT
(defun du/pares-date-to-list (origin)
(let* ((origin-list (split-string origin))
(result-data nil))
(let ((i 0))
(dolist (item origin-list)
(cond ((= i 0)
(push (cons 'day-of-week (substring item 0 (- (string-width item) 1))) result-data))
((= i 1)
(push (cons 'day item) result-data))
((= i 2)
(push (cons 'month item) result-data))
((= i 3)
(push (cons 'year item) result-data))
((= i 4)
(let ((time-list (split-string item ":")))
(push (cons 'second (nth 2 time-list)) result-data)
(push (cons 'minute (nth 1 time-list)) result-data)
(push (cons 'hour (nth 0 time-list)) result-data)))
((= i 5)
(push (cons 'zone item) result-data))
(t nil))
(setq i (+ 1 i)))
)
result-data))
(defun du/parse-date-hour (origin)
)
(defun du/test ()
"du test"
(interactive)
(let* ((date-string "Sun, 19 Jun 2016 03:02:30 GMT")
(date-list (du/pares-date-to-list date-string)))
(unless (listp date-list)
(error "not a list!"))
(dolist (item date-list)
(message "%s:%s" (symbol-name (car item)) (cdr item)))
)
)
(provide 'date-utils)