[cl-l10n-cvs] CVS update: cl-l10n/ChangeLog cl-l10n/cl-l10n.asd cl-l10n/printers.lisp cl-l10n/tests.lisp cl-l10n/utils.lisp
Sean Ross
sross at common-lisp.net
Wed Mar 23 10:58:18 UTC 2005
Update of /project/cl-l10n/cvsroot/cl-l10n
In directory common-lisp.net:/tmp/cvs-serv11902
Modified Files:
ChangeLog cl-l10n.asd printers.lisp tests.lisp utils.lisp
Log Message:
Changelog 2005-03-23
Date: Wed Mar 23 11:58:16 2005
Author: sross
Index: cl-l10n/ChangeLog
diff -u cl-l10n/ChangeLog:1.12 cl-l10n/ChangeLog:1.13
--- cl-l10n/ChangeLog:1.12 Thu Mar 17 12:40:34 2005
+++ cl-l10n/ChangeLog Wed Mar 23 11:58:16 2005
@@ -1,6 +1,9 @@
+2005-03-23 Sean Ross <sross at common-lisp.net>
+ * printers.lisp: Fixed the %w, %e, %x, %X, %d and %j time format directives.
+ * tests.lisp: Added a test for each supported time format directive.
+
2005-03-17 Sean Ross <sross at common-lisp.net>
- * doc/cl-l10n.texi: Cleaned up so that it
- works with makeinfo.
+ * doc/cl-l10n.texi: Cleaned up so that it works with makeinfo.
2005-02-22 Sean Ross <sross at common-lisp.net>
* printers.lisp: Added a formatter compiler macro
Index: cl-l10n/cl-l10n.asd
diff -u cl-l10n/cl-l10n.asd:1.9 cl-l10n/cl-l10n.asd:1.10
--- cl-l10n/cl-l10n.asd:1.9 Tue Feb 22 15:18:25 2005
+++ cl-l10n/cl-l10n.asd Wed Mar 23 11:58:16 2005
@@ -11,7 +11,7 @@
:name "CL-L10N"
:author "Sean Ross <sdr at jhb.ucs.co.za>"
:maintainer "Sean Ross <sdr at jhb.ucs.co.za>"
- :version "0.2.3"
+ :version "0.2.5"
:description "Portable CL Locale Support"
:long-description "Portable CL Package to support localization"
:licence "MIT"
Index: cl-l10n/printers.lisp
diff -u cl-l10n/printers.lisp:1.10 cl-l10n/printers.lisp:1.11
--- cl-l10n/printers.lisp:1.10 Tue Feb 22 15:18:25 2005
+++ cl-l10n/printers.lisp Wed Mar 23 11:58:16 2005
@@ -36,9 +36,8 @@
(defun print-number (number &key (stream *standard-output*)
no-ts no-dp (locale *locale*))
- (let ((locale (locale-des->locale locale)))
- (format-number stream number no-dp no-ts locale)
- number))
+ (format-number stream number no-dp no-ts locale)
+ number)
;; Money
@@ -86,9 +85,8 @@
(defun print-money (num &key (stream *standard-output*) use-int-sym no-ts
(locale *locale*))
- (let ((locale (locale-des->locale locale)))
- (format-money stream num use-int-sym no-ts locale)
- num))
+ (format-money stream num use-int-sym no-ts locale)
+ num)
;; ;; Time and date printing.
(defun get-time-fmt-string (locale show-date show-time)
@@ -119,12 +117,19 @@
it
(locale-error "No format directive for char ~S." char)))
-(defun princ-pad-val (val stream &optional (pad "0"))
+(defun princ-pad-val (val stream &optional (pad "0") (size 2))
(declare (type stream stream) (optimize speed)
(type fixnum val))
- (when (< val 10)
- (princ pad stream))
- (princ val stream))
+ (assert (not (minusp val)) (val) "Value ~A cannot be smaller than 0." val)
+ (cond ((zerop val)
+ (dotimes (x (1- size))
+ (princ pad stream))
+ (princ 0 stream))
+ (t
+ (loop for x = (* val 10) then (* x 10)
+ until (>= x (expt 10 size)) do
+ (princ pad stream))
+ (princ val stream))))
(defun last-2-digits (val)
(mod val 100))
@@ -139,17 +144,16 @@
(if (> day 6) (decf day 7))
(princ (nth day (locale-day locale)) stream)))
-
(def-formatter #\b
- (cl:format stream (cl:formatter "~:(~A~)")
+ (cl:format stream (cl:formatter "~A")
(nth (1- month) (locale-abmon locale))))
(def-formatter #\B
- (cl:format stream (cl:formatter "~:(~A~)")
+ (cl:format stream (cl:formatter "~A")
(nth (1- month) (locale-mon locale))))
(def-formatter #\c
- (print-time-string "%a %b %d %T %Z %Y" stream ut locale))
+ (print-time-string (locale-d-t-fmt locale) stream ut locale))
(def-formatter #\C
(princ-pad-val (truncate (/ year 100)) stream))
@@ -161,7 +165,7 @@
(print-time-string "%m/%d/%y" stream ut locale))
(def-formatter #\e
- (princ-pad-val month stream " "))
+ (princ-pad-val date stream " "))
(def-formatter #\F
(print-time-string "%Y-%m-%d" stream ut locale))
@@ -202,7 +206,7 @@
(incf total date)))
(def-formatter #\j
- (princ (day-of-year date month year) stream))
+ (princ-pad-val (day-of-year date month year) stream "0" 3))
(def-formatter #\k
(princ-pad-val hour stream " "))
@@ -236,7 +240,7 @@
stream))
(def-formatter #\r
- (print-time-string "%X %p" stream ut locale))
+ (print-time-string "%H:%M:%S %p" stream ut locale))
(def-formatter #\R
(print-time-string "%H:%M" stream ut locale))
@@ -253,7 +257,7 @@
(princ #\Tab stream))
(def-formatter #\T
- (print-time-string "%X" stream ut locale))
+ (print-time-string "%H:%M:%S" stream ut locale))
(def-formatter #\u
(let ((day (1+ day)))
@@ -269,19 +273,19 @@
(locale-error "Unsupported time format directive ~S." #\V))
(def-formatter #\w
- (let ((day (1- day)))
- (if (< day 0) (incf day 7))
- (princ day stream)))
+ (let ((day (1+ day)))
+ (when (>= day 7) (decf day 7))
+ (princ day stream)))
;; FIXME
(def-formatter #\W
(locale-error "Unsupported time format directive ~S." #\W))
(def-formatter #\x
- (print-time-string "%m/%d/%y" stream ut locale))
+ (print-time-string (locale-d-fmt locale) stream ut locale))
(def-formatter #\X
- (print-time-string "%R:%S" stream ut locale))
+ (print-time-string (locale-t-fmt locale) stream ut locale))
(def-formatter #\y
(princ-pad-val (last-2-digits year) stream))
@@ -326,9 +330,8 @@
(defun print-time (ut &key show-date show-time (stream *standard-output*)
(locale *locale*) fmt)
- (let ((locale (locale-des->locale locale)))
- (format-time stream ut show-date show-time locale fmt)
- ut))
+ (format-time stream ut show-date show-time locale fmt)
+ ut)
;; Format
Index: cl-l10n/tests.lisp
diff -u cl-l10n/tests.lisp:1.5 cl-l10n/tests.lisp:1.6
--- cl-l10n/tests.lisp:1.5 Tue Feb 1 08:58:25 2005
+++ cl-l10n/tests.lisp Wed Mar 23 11:58:16 2005
@@ -77,7 +77,7 @@
(deftest time.2
(format nil "~v:@/cl-l10n:format-time/" "sv_SE" 3091103120)
- "sön 12 Dec 1997 17.45.20")
+ "sön 14 dec 1997 17.45.20")
(deftest time.3
(format nil "~v/cl-l10n:format-time/" "en_US" 3091103120)
@@ -95,26 +95,55 @@
(format nil "~v@/cl-l10n:format-time/" "sv_SE" 3091103120)
"17.45.20")
-(defparameter *full-test*
- (format nil "%% %a %A %b %B %c %C %d %D %e %F %g %G %h %H %I ~
-%j %k %l %m %M %n %N %p %P %r %R %S %t %T %u %w %x %X %y %z %Z"))
-
-(deftest time.7
- (format nil "~v,v/cl-l10n:format-time/" "en_ZA" *full-test* 3091103120)
- "% Sun Sunday Dec December Sun Dec 14 17:45:20 +0200 1997 19 14 12/14/97 12 1997-12-14 97 1997 Dec 17 05 348 17 5 12 45
- 000000000 17:45:20 17:45 20 17:45:20 7 5 12/14/97 17:45:20 97 +0200 +0200")
-
-
-(deftest time.8
- (format nil "~v,v/cl-l10n:format-time/" "en_US" *full-test* 3091103120)
- "% Sun Sunday Dec December Sun Dec 14 17:45:20 +0200 1997 19 14 12/14/97 12 1997-12-14 97 1997 Dec 17 05 348 17 5 12 45
- 000000000 17:45:20 17:45 20 17:45:20 7 5 12/14/97 17:45:20 97 +0200 +0200")
-
-(deftest time.9
- (format nil "~v,v/cl-l10n:format-time/" "sv_SE" *full-test* 3091103120)
-"% sön söndag Dec December sön Dec 14 17:45:20 +0200 1997 19 14 12/14/97 12 1997-12-14 97 1997 dec 17 05 348 17 5 12 45
- 000000000 17:45:20 17:45 20 17:45:20 7 5 12/14/97 17:45:20 97 +0200 +0200")
-
+(defmacro def-time-directive-test (name directive result)
+ `(deftest ,name (format nil "~v,vU" "en_ZA" ,directive 3320556360)
+ ,result))
+
+(def-time-directive-test directive.1 "%%" "%")
+(def-time-directive-test directive.2 "%a" "Wed")
+(def-time-directive-test directive.3 "%A" "Wednesday")
+(def-time-directive-test directive.4 "%b" "Mar")
+(def-time-directive-test directive.5 "%B" "March")
+(def-time-directive-test directive.6 "%c" "Wed 23 Mar 2005 10:46:00 +0200")
+(def-time-directive-test directive.7 "%C" "20")
+(def-time-directive-test directive.8 "%d" "23")
+(def-time-directive-test directive.9 "%D" "03/23/05")
+(def-time-directive-test directive.10 "%e" "23")
+(def-time-directive-test directive.11 "%F" "2005-03-23")
+(def-time-directive-test directive.12 "%g" "05")
+(def-time-directive-test directive.13 "%G" "2005")
+(def-time-directive-test directive.14 "%h" "Mar")
+(def-time-directive-test directive.15 "%H" "10")
+(def-time-directive-test directive.16 "%I" "10")
+(def-time-directive-test directive.17 "%j" "082")
+(def-time-directive-test directive.18 "%k" "10")
+(def-time-directive-test directive.19 "%l" "10")
+(def-time-directive-test directive.21 "%m" "03")
+(def-time-directive-test directive.22 "%M" "46")
+(def-time-directive-test directive.23 "%n" "
+")
+(def-time-directive-test directive.24 "%N" "000000000")
+(def-time-directive-test directive.25 "%p" "")
+(def-time-directive-test directive.26 "%P" "")
+(def-time-directive-test directive.27 "%r" "10:46:00 ")
+(def-time-directive-test directive.28 "%R" "10:46")
+(def-time-directive-test directive.29 "%s" "1111567560")
+(def-time-directive-test directive.30 "%S" "00")
+(def-time-directive-test directive.31 "%t" " ")
+(def-time-directive-test directive.32 "%T" "10:46:00")
+(def-time-directive-test directive.33 "%u" "3")
+;(def-time-directive-test directive.34 "%U" "12")
+;(def-time-directive-test directive.35 "%V" "12")
+(def-time-directive-test directive.36 "%w" "3")
+;(def-time-directive-test directive.37 "%W" "12")
+(def-time-directive-test directive.38 "%x" "23/03/2005")
+(def-time-directive-test directive.39 "%X" "10:46:00")
+(def-time-directive-test directive.40 "%y" "05")
+(def-time-directive-test directive.41 "%Y" "2005")
+(def-time-directive-test directive.42 "%z" "+0200")
+(def-time-directive-test directive.43 "%Z" "+0200")
+
+
;; i18n tests
(defvar *my-bundle* (make-instance 'bundle))
Index: cl-l10n/utils.lisp
diff -u cl-l10n/utils.lisp:1.5 cl-l10n/utils.lisp:1.6
--- cl-l10n/utils.lisp:1.5 Thu Dec 30 12:56:38 2004
+++ cl-l10n/utils.lisp Wed Mar 23 11:58:16 2005
@@ -48,11 +48,6 @@
(and (consp list)
(not (cdr list))))
-(defun mklist (thing)
- (if (listp thing)
- thing
- (list thing)))
-
(defun last1 (list)
(car (last list)))
More information about the Cl-l10n-cvs
mailing list