Permalink
Browse files

Minor refactoring of ordinalize

  • Loading branch information...
1 parent 996e4eb commit 130cbb77f57a2e4d56be7224bcf8c2fd26284475 @dlowe-net committed Oct 16, 2011
Showing with 8 additions and 11 deletions.
  1. +8 −11 src/local-time.lisp
View
@@ -1553,17 +1553,14 @@ elements."
(defun ordinalize (day)
"Return an ordinal string representing the position of DAY in a sequence (1st, 2nd, 3rd, 4th, etc)."
(declare (type (integer 1 31) day))
- (flet ((suffix ()
- (if (<= 11 day 13)
- "th"
- (multiple-value-bind (quotient remainder) (floor day 10)
- (declare (ignore quotient))
- (case remainder
- (1 "st")
- (2 "nd")
- (3 "rd")
- (t "th"))))))
- (format nil "~d~a" day (suffix))))
+ (format nil "~d~a" day
+ (if (<= 11 day 13)
+ "th"
+ (case (mod day 10)
+ (1 "st")
+ (2 "nd")
+ (3 "rd")
+ (t "th")))))
(defun %construct-timestring (timestamp format timezone)
"Constructs a string representing TIMESTAMP given the FORMAT of the string and the TIMEZONE. See the documentation of FORMAT-TIMESTRING for the structure of FORMAT."

0 comments on commit 130cbb7

Please sign in to comment.