Skip to content

Commit

Permalink
Moved datetime data to correct place, exported MONTH-NAME and DOW-NAME.
Browse files Browse the repository at this point in the history
  • Loading branch information
chaitanyagupta committed Apr 4, 2009
1 parent 9d347cb commit c820b61
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 41 deletions.
37 changes: 0 additions & 37 deletions src/chronicity.lisp
Expand Up @@ -178,43 +178,6 @@ matching instance of that time will be used."
(defgeneric scan-tokens (tag tokens)
(:documentation "Scan the list of TOKENS and tag the appropriately."))
;;; Data
(defparameter *months*
(list :JANUARY
:FEBRUARY
:MARCH
:APRIL
:MAY
:JUNE
:JULY
:AUGUST
:SEPTEMBER
:OCTOBER
:NOVEMBER
:DECEMBER))
(defun month-name (index)
(elt *months* (1- index)))
(defun month-index (name)
(1+ (position name *months*)))
(defparameter *days-of-week*
(list :SUNDAY
:MONDAY
:TUESDAY
:WEDNESDAY
:THURSDAY
:FRIDAY
:SATURDAY))
(defun dow-index (name)
(position name *days-of-week*))
(defun dow-name (index)
(elt *days-of-week* index))
;;; Disable CL-INTERPOL's special reader syntax
#.(cl-interpol:disable-interpol-syntax)
Expand Down
43 changes: 42 additions & 1 deletion src/datetime.lisp
Expand Up @@ -20,6 +20,9 @@
(defun make-datetime (year &optional (month 1) (day 1) (hour 0) (minute 0) (sec 0))
(local-time:encode-timestamp 0 sec minute hour day month year))

(defun datetimep (x)
(typep x 'local-time:timestamp))

(defun copy-date (from &key
(year (year-of from))
(month (month-of from))
Expand Down Expand Up @@ -208,6 +211,9 @@
(defun make-span (start end &optional (end-included-p nil))
(make-instance 'span :start start :end end :end-included-p end-included-p))

(defun spanp (x)
(typep x 'span))

(defun span-width (span)
(- (datetime-to-universal (span-end span))
(datetime-to-universal (span-start span))))
Expand All @@ -226,5 +232,40 @@
(and (datetime<= (span-start span) datetime)
(datetime< datetime (span-end span)))))


;;; Miscellaneous data

(defparameter *months*
(list :JANUARY
:FEBRUARY
:MARCH
:APRIL
:MAY
:JUNE
:JULY
:AUGUST
:SEPTEMBER
:OCTOBER
:NOVEMBER
:DECEMBER))

(defun month-name (index)
(elt *months* (1- index)))

(defun month-index (name)
(1+ (position name *months*)))

(defparameter *days-of-week*
(list :SUNDAY
:MONDAY
:TUESDAY
:WEDNESDAY
:THURSDAY
:FRIDAY
:SATURDAY))

(defun dow-index (name)
(position name *days-of-week*))

(defun dow-name (index)
(elt *days-of-week* index))

13 changes: 10 additions & 3 deletions src/packages.lisp
Expand Up @@ -13,9 +13,10 @@
#:*guess*
#:*ambiguous-time-range*
#:*endian-preference*
;; Date/time
;; Datetime
#:datetime
#:make-datetime
#:datetimep
#:make-date
#:year-of
#:month-of
Expand All @@ -25,9 +26,15 @@
#:sec-of
#:dow-of
;; Span
#:span
#:spanp
#:span-start
#:span-end
#:span-end-included-p)
#:span-end-included-p
;; Miscellaneous datetime data
#:month-name
#:dow-name
;; Token
#:token-word
#:token-tags)
(:import-from #:cl-ppcre #:scan))

0 comments on commit c820b61

Please sign in to comment.