[cl-l10n-cvs] CVS update: cl-l10n/ChangeLog cl-l10n/README cl-l10n/cl-l10n.asd cl-l10n/load-locale.lisp cl-l10n/locale.lisp cl-l10n/package.lisp cl-l10n/parse-number.lisp cl-l10n/parse-time.lisp cl-l10n/printers.lisp cl-l10n/tests.lisp

Sean Ross sross at common-lisp.net
Thu Mar 31 13:53:47 UTC 2005


Update of /project/cl-l10n/cvsroot/cl-l10n
In directory common-lisp.net:/tmp/cvs-serv7026

Modified Files:
	ChangeLog README cl-l10n.asd load-locale.lisp locale.lisp 
	package.lisp parse-number.lisp parse-time.lisp printers.lisp 
	tests.lisp 
Log Message:
Changelog 2005-03-31
Date: Thu Mar 31 15:53:42 2005
Author: sross

Index: cl-l10n/ChangeLog
diff -u cl-l10n/ChangeLog:1.15 cl-l10n/ChangeLog:1.16
--- cl-l10n/ChangeLog:1.15	Wed Mar 30 13:14:53 2005
+++ cl-l10n/ChangeLog	Thu Mar 31 15:53:42 2005
@@ -1,3 +1,22 @@
+2005-03-31 Sean Ross	<sross at common-lisp.net>
+	Version 0.3 Release
+	* parse-time.lisp, load-locale.lisp: Create
+	more comprehensive time parsers for each locale
+	at locale load time. 02/03/04 now parses correctly.
+	* tests.lisp: Added tests for the time parser.
+	* printers.lisp: Added a time-zone argument to format-time
+	and print-time.
+	* parse-number.lisp: Changed invalid-number condition to
+	parser-error condition.
+	* parse-time.lisp: Changed errors which are signalled during
+	parsing to be of type parser-error.
+	* locale.lisp: Changed superclass of locale-error to be error.
+	* tests.lisp: Changed all time related tests to use
+	a default time zone since they were crashing when running
+	in a zone other than +0200 (-2 CL Zone).
+	* doc/cl-l10n.texi: Made current and added full listing of 
+	locale accessor functions and time format control characters.
+	
 2005-03-30 Sean Ross	<sross at common-lisp.net>
 	* parse-time.lisp: New file borrowed from cmucl with
 	minor changes to be less hostile towards non english 
@@ -23,7 +42,7 @@
 	* 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 
+	* printers.lisp: Added a format compiler macro 
 	to remove unnecessary calls to parse-fmt-string.
 	* load-locale.lisp: Added a loader for the locale 
 	function which will be called if passed in.


Index: cl-l10n/README
diff -u cl-l10n/README:1.2 cl-l10n/README:1.3
--- cl-l10n/README:1.2	Thu Dec 30 12:56:38 2004
+++ cl-l10n/README	Thu Mar 31 15:53:42 2005
@@ -3,18 +3,22 @@
 Homepage: http://www.common-lisp.net/project/cl-l10n/
 
 
-
 0. About
 cl-l10n is a localization package for common-lisp. It is meant 
 to be serve the same purpose as Allegro Common Lisp's
 various locale functions. It currently runs on 
-CMUCL, SBCL, CLISP, ECL and Lispworks although porting to a new
-implementation should be ridiculously trivial.
+CMUCL, SBCL, CLISP, ECL, Lispworks and Allegro CL although porting 
+to a new implementation should be trivial.
 
 
 1. API
-Check docs/cl-l10n.texi
+See docs/cl-l10n.texi
+
 
+2. Testing
+Run (asdf:oos 'asdf:test-op :cl-l10n) to test the package.
+If any tests fail please drop me a line at the mailing lists
+or at (sross <at> common-lisp.net).
 
 Enjoy 
   Sean.


Index: cl-l10n/cl-l10n.asd
diff -u cl-l10n/cl-l10n.asd:1.12 cl-l10n/cl-l10n.asd:1.13
--- cl-l10n/cl-l10n.asd:1.12	Wed Mar 30 13:14:53 2005
+++ cl-l10n/cl-l10n.asd	Thu Mar 31 15:53:42 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.9"
+  :version "0.3"
   :description "Portable CL Locale Support"
   :long-description "Portable CL Package to support localization"
   :licence "MIT"
@@ -22,7 +22,7 @@
                (:file "load-locale" :depends-on ("locale"))
                (:file "printers" :depends-on ("load-locale"))
                (:file "parsers" :depends-on ("printers" "parse-number"))
-               (:file "parse-time" :depends-on ("parsers"))
+               (:file "parse-time" :depends-on ("load-locale"))
                (:file "i18n" :depends-on ("printers")))
   :depends-on (:cl-ppcre))
 


Index: cl-l10n/load-locale.lisp
diff -u cl-l10n/load-locale.lisp:1.11 cl-l10n/load-locale.lisp:1.12
--- cl-l10n/load-locale.lisp:1.11	Thu Mar 24 15:47:01 2005
+++ cl-l10n/load-locale.lisp	Thu Mar 31 15:53:42 2005
@@ -60,6 +60,7 @@
                                                             escape comment))
               (setf (get-category locale (category-name it)) it)))))
       (add-printers locale)
+      (add-parsers locale)
       locale)))
 
 (defun load-all-locales (&optional (path *locale-path*))
@@ -140,6 +141,53 @@
                      (create-money-fmt-string locale nil t))
                (printers locale))))
 
+(defun day-element-p (x)
+  (member x '(#\d #\e)))
+
+(defun month-element-p (x)
+  (char= x #\m))
+
+(defun year-element-p (x)
+  (member x '(#\y #\Y)))
+
+(defun element-type (char)
+  (cond ((day-element-p char) 'day)
+        ((month-element-p char) 'month)
+        ((year-element-p char) 'year)))
+
+(defvar date-dividers '(#\\ #\/ #\-))
+
+;; FIXME
+;; this effort definitely doesn't cover
+;; every single case but it will do for now.
+(defun locale-date-month-order (locale)
+  (let ((fmt (locale-d-fmt locale)))
+    (cond ((string= fmt "%D") '(month day year))
+          ((string= fmt "%F") '(year month day))
+          (t (compute-order fmt)))))
+
+(defun compute-order (fmt)
+  (let ((res nil))
+    (loop for char across fmt 
+          with perc = nil do
+          (cond ((char= char #\%) (setf perc (not perc)))
+                ((member char date-dividers) nil)
+                (perc (let ((val (element-type char)))
+                        (when val (push val res))
+                        (setf perc nil)))))
+    (nreverse res)))
+
+
+(defun add-parsers (locale)
+  (destructuring-bind (first second third)
+      (locale-date-month-order locale)
+    (setf (parsers locale)
+          (list `((noon-midn) (weekday) ,first (date-divider) ,second (date-divider) ,third (noon-midn))
+                `((weekday) ,first (date-divider) ,second (date-divider) ,third hour (time-divider) minute
+                  (time-divider) (secondp) (am-pm) (date-divider) (zone))
+                `(hour (time-divider) minute (time-divider) (secondp) (am-pm) (weekday) ,first (date-divider) 
+                       (secondp) (date-divider) ,third (date-divider) (zone))))))
+
 (defvar *category-loaders*
   '(("LC_IDENTIFICATION" . load-identification)
     ("LC_MONETARY" . load-category)
@@ -308,7 +356,7 @@
              (notany #'(lambda (x)
                          (search x line :test #'string=))
                      *ignore-categories*))
-        (return-from next-header line))))
+        (return-from next-header (trim line)))))
 
 (defun load-default-locale ()
   (setf *locale* (get-default-locale)))


Index: cl-l10n/locale.lisp
diff -u cl-l10n/locale.lisp:1.8 cl-l10n/locale.lisp:1.9
--- cl-l10n/locale.lisp:1.8	Tue Feb 22 15:18:25 2005
+++ cl-l10n/locale.lisp	Thu Mar 31 15:53:42 2005
@@ -4,8 +4,8 @@
 ;; TODO
 ;;  What to do with LC_CTYPE, LC_COLLATE
 ;;  Test on windows.
-;;  Parsers (money and time)
-;;  locale aliases
+;;  Parsers (money)
+;;  locale aliases?
 ;;  Optimizing print-time
 ;;  Thread safety
 
@@ -24,7 +24,7 @@
 (defun locale-report (obj stream)
   (cl:format stream "~A" (mesg obj)))
 
-(define-condition locale-error ()
+(define-condition locale-error (error)
   ((mesg :accessor mesg :initarg :mesg :initform "Unknown."))
   (:report locale-report))
 
@@ -37,6 +37,7 @@
                 :initform (required-arg :name))
    (title :accessor title :initarg :title :initform nil)
    (printers :accessor printers :initarg :printers :initform nil)
+   (parsers :accessor parsers :initarg :parsers :initform nil)
    (source :accessor source :initarg :source :initform nil)
    (language :accessor language :initarg :language :initform nil)
    (territory :accessor territory :initarg :territory :initform nil)


Index: cl-l10n/package.lisp
diff -u cl-l10n/package.lisp:1.5 cl-l10n/package.lisp:1.6
--- cl-l10n/package.lisp:1.5	Wed Mar 30 13:14:53 2005
+++ cl-l10n/package.lisp	Thu Mar 31 15:53:42 2005
@@ -13,5 +13,5 @@
            #:add-resource #:gettext #:parse-number #:*float-digits*
            #:parse-time #:month #:day #:year #:hour #:minute #:second
            #:date-divider #:time-divider #:weekday #:noon-midn 
-           #:secondp #:am-pm #:zone))
+           #:secondp #:am-pm #:zone #:parser-error))
            


Index: cl-l10n/parse-number.lisp
diff -u cl-l10n/parse-number.lisp:1.3 cl-l10n/parse-number.lisp:1.4
--- cl-l10n/parse-number.lisp:1.3	Thu Dec 30 12:56:38 2004
+++ cl-l10n/parse-number.lisp	Thu Mar 31 15:53:42 2005
@@ -32,7 +32,7 @@
 
 (in-package #:cl-l10n)
 
-(define-condition invalid-number ()
+(define-condition parser-error (error)
   ((value :reader value
 	  :initarg :value
 	  :initform nil)
@@ -40,7 +40,7 @@
 	   :initarg :reason
 	   :initform "Not specified"))
   (:report (lambda (c s)
-	     (cl:format s "Invalid number: ~S [Reason: ~A]"
+	     (cl:format s "Unable to parse: ~S [Reason: ~A]"
                    (value c) (reason c)))))
 
 (declaim (inline parse-integer-and-places))
@@ -106,7 +106,7 @@
 (defun %parse-number (string &key (start 0) (end nil) (radix 10))
   "Given a string, and start, end, and radix parameters, produce a number according to the syntax definitions in the Common Lisp Hyperspec."
   (flet ((invalid-number (reason)
-	   (error 'invalid-number
+	   (error 'parser-error
 		  :value (subseq string start end)
 		  :reason reason)))
     (let ((end (or end (length string))))
@@ -179,7 +179,7 @@
 				       :end end
 				       :key #'char-downcase)))
 		  (unless r-pos
-		    (error 'invalid-number
+		    (error 'parser-error
 			   :value (subseq string start end)
 			   :reason "Missing R in #radixR"))
 		  (parse-real-number string
@@ -198,7 +198,7 @@
   (let ((end (or end (length string)))
 	(first-char (char string start)))
     (flet ((invalid-number (reason)
-	     (error 'invalid-number
+	     (error 'parser-error
 		    :value (subseq string start end)
 		    :reason reason))
 	   (base-for-exponent-marker (char)


Index: cl-l10n/parse-time.lisp
diff -u cl-l10n/parse-time.lisp:1.1 cl-l10n/parse-time.lisp:1.2
--- cl-l10n/parse-time.lisp:1.1	Wed Mar 30 13:23:56 2005
+++ cl-l10n/parse-time.lisp	Thu Mar 31 15:53:42 2005
@@ -13,14 +13,13 @@
 ;;; **********************************************************************
 
 ;; This has been borrowed and  slightly modified to be more friendly
-;; towards non english time strings and differing locales. 
+;; towards non english time strings and locales. 
 ;; Sean Ross 29 March 2005.
 
 (in-package :cl-l10n)
 
 (defvar whitespace-chars '(#\space #\tab #\newline #\, #\' #\`))
 (defvar time-dividers '(#\: #\.))
-(defvar date-dividers '(#\\ #\/ #\-))
 
 (defvar *error-on-mismatch* nil
   "If t, an error will be signalled if parse-time is unable
@@ -69,7 +68,12 @@
 ;;; year, time-divider, date-divider, am-pm, zone, izone, weekday,
 ;;; noon-midn, and any special symbol.
 
-; TODO (add more linux like dates. eg 3 days ago)
+#|
+
+
+
+|#
+
 
 (defparameter *default-date-time-patterns*
   '( 
@@ -88,13 +92,9 @@
     ((noon-midn) month (date-divider) year)
     ((noon-midn) year (date-divider) month)
 
-     ;; Time formats.
-    (hour (time-divider) (minute) (time-divider) (secondp) (am-pm) 
-	  (date-divider) (zone))
-    (noon-midn)
-    (hour (noon-midn))
 
-     ;; Time/date combined formats.
+ ;; Time/date combined formats.
+
     ((weekday) month (date-divider) day (date-divider) year
 	   hour (time-divider) (minute) (time-divider) (secondp)
 	   (am-pm) (date-divider) (zone))
@@ -131,6 +131,13 @@
     (hour (time-divider) (minute) (time-divider) (secondp) (am-pm)
 	  (date-divider) (zone) year (date-divider) month)
 
+
+     ;; Time formats.
+    (hour (time-divider) (minute) (time-divider) (secondp) (am-pm) 
+	  (date-divider) (zone))
+    (noon-midn)
+    (hour (noon-midn))
+
      ;; Weird, non-standard formats.
     (weekday month day hour (time-divider) minute (time-divider)
 	     secondp (am-pm)
@@ -402,8 +409,9 @@
 	(let ((test-value (special-string-p substring)))
 	  (if test-value  (cons 'special test-value)))
 	(if *error-on-mismatch*
-	    (error "\"~A\" is not a recognized word or abbreviation."
-		   substring)
+            (error 'parser-error
+		  :value substring
+		  :reason "Not a recognized word or abbreviation.")
 	    (return-from match-substring nil)))))
 
 ;;; Decompose-string takes the time/date string and decomposes it into a
@@ -473,11 +481,9 @@
 	    (t
 	     ;; Unrecognized character - barf voraciously.
 	     (if *error-on-mismatch*
-		 (error
-		  'simple-error
-		  :format-control "Can't parse time/date string.~%>>> ~A~
-				   ~%~VT^-- Bogus character encountered here."
-		  :format-arguments (list string (+ string-index 4)))
+                 (error 'parser-error
+                        :value string
+                        :reason "Can't parse time/date string. Bogus character encountered.")
 		 (return-from decompose-string nil)))))))
 
 ;;; Match-pattern-element tries to match a pattern element with a datum
@@ -533,7 +539,8 @@
 	 (setf (decoded-time-hour parsed-values) 12))
 	((eq form-value 'midn)
 	 (setf (decoded-time-hour parsed-values) 0))
-	(t (error "Unrecognized symbol: ~A" form-value)))
+	(t (error 'parser-error :value form-value
+                  :reason "Unrecognized symbol.")))
   (setf (decoded-time-minute parsed-values) 0)
   (setf (decoded-time-second parsed-values) 0))
 
@@ -548,12 +555,12 @@
 		  (setf (decoded-time-hour parsed-values) 0))
 		 ((not (<= 0 hour 12))
 		  (if *error-on-mismatch*
-		      (error "~D is not an AM hour, dummy." hour)))))
+		      (error 'parser-error :value hour :reason "Not an AM hour, dummy.")))))
 	  ((eq form-value 'pm)
 	   (if (<= 0 hour 11)
 	       (setf (decoded-time-hour parsed-values)
 		     (mod (+ hour 12) 24))))
-	  (t (error "~A isn't AM/PM - this shouldn't happen."
+	  (t (error 'parser-error :value form-value :reason "Not an AM/PM - this shouldn't happen."
 		    form-value)))))
 
 ;;; Internet numerical time zone, e.g. RFC1123, in hours and minutes.
@@ -582,47 +589,8 @@
 	(am-pm (deal-with-am-pm form-value parsed-values))
 	(noon-midn (deal-with-noon-midn form-value parsed-values))
 	(special (funcall form-value parsed-values))
-	(t (error "Unrecognized symbol in form list: ~A." form-type))))))
-
-(defun day-element-p (x)
-  (member x '(#\d #\e)))
-
-(defun month-element-p (x)
-  (char= x #\m))
+        (t (error 'parser-error :value form-type :reason "Unrecognized symbol in form list."))))))
 
-(defun year-element-p (x)
-  (member x '(#\y #\Y)))
-
-(defun element-type (char)
-  (cond ((day-element-p char) 'day)
-        ((month-element-p char) 'month)
-        ((year-element-p char) 'year)))
-
-;; FIXME
-;; this effort definitely doesn't cover
-;; every single case but it will do for now.
-(defun locale-date-month-order ()
-  (let ((fmt (locale-d-fmt)))
-    (cond ((string= fmt "%D") '(month day year))
-          ((string= fmt "%F") '(year month day))
-          (t (compute-order fmt)))))
-
-(defun compute-order (fmt)
-  (let ((res nil))
-    (loop for char across fmt 
-          with perc = nil do
-          (cond ((char= char #\%) (setf perc (not perc)))
-                ((member char date-dividers) nil)
-                (perc (let ((val (element-type char)))
-                        (when val (push val res))
-                        (setf perc nil)))))
-    (nreverse res)))
-
-(defun locale-date-pattern ()
-  (let ((order (locale-date-month-order)))
-    (when order
-      (loop for x in order
-            append (list x '(date-divider))))))
 
 (defun default-patterns-p (patterns)
   (eq patterns *default-date-time-patterns*))
@@ -632,11 +600,12 @@
     ;; patterns have not been explicitly specified so we try
     ;; to match against locale a specific date pattern first.
     ;; eg. 03/04/2005 is 3rd April in UK but 4 March in US.
-    (let ((res (match-pattern (locale-date-pattern)
-                              string-parts
-                              parts-length)))
-      (when res
-        (return-from get-matching-pattern res))))
+    (dolist (pattern (parsers *locale*))
+      (let ((res (match-pattern pattern
+                                string-parts
+                                parts-length)))
+        (when res
+          (return-from get-matching-pattern res)))))
   (dolist (pattern patterns)
     (let ((match-result (match-pattern pattern string-parts
                                        parts-length)))
@@ -652,8 +621,8 @@
 			       (default-month nil) (default-year nil)
 			       (default-zone nil) (default-weekday nil)
                                (locale *locale*))
-  "Tries very hard to make sense out of the argument time-string and
-   returns a single integer representing the universal time if
+  "Tries very hard to make sense out of the argument time-string using
+   locale and returns a single integer representing the universal time if
    successful.  If not, it returns nil.  If the :error-on-mismatch
    keyword is true, parse-time will signal an error instead of
    returning nil.  Default values for each part of the time/date
@@ -674,7 +643,7 @@
 	  (set-time-values string-form parsed-values)
 	  (convert-to-unitime parsed-values))
 	(if *error-on-mismatch*
-	  (error "\"~A\" is not a recognized time/date format." time-string)
+            (error 'parser-error :value time-string :reason "Not a recognized time/date format.")
 	  nil))))
 
 


Index: cl-l10n/printers.lisp
diff -u cl-l10n/printers.lisp:1.13 cl-l10n/printers.lisp:1.14
--- cl-l10n/printers.lisp:1.13	Wed Mar 30 13:14:54 2005
+++ cl-l10n/printers.lisp	Thu Mar 31 15:53:42 2005
@@ -314,9 +314,11 @@
 (def-formatter #\Z
   (print-time-string "%z" stream ut locale))
 
-(defun format-time (stream ut show-date show-time &optional (locale *locale*) 
-                           fmt)
-  (let ((locale (locale-des->locale (or locale *locale*))))
+(defvar *time-zone* (nth-value 8 (get-decoded-time)))
+
+(defun format-time (stream ut show-date show-time &optional (locale *locale*) fmt time-zone)
+  (let ((locale (locale-des->locale (or locale *locale*)))
+        (*time-zone* (or time-zone *time-zone*)))
     (print-time-string (or fmt (get-time-fmt-string locale 
                                                     show-date show-time))
                        stream ut locale))
@@ -324,7 +326,7 @@
 
 (defun print-time-string (fmt-string stream ut locale)
   (declare (optimize speed) (type simple-string fmt-string))
-  (let ((values (multiple-value-list (decode-universal-time ut))))
+  (let ((values (multiple-value-list (decode-universal-time ut *time-zone*))))
     (loop for x across fmt-string 
           with perc = nil do
           (case x 
@@ -338,8 +340,8 @@
                    (princ x stream)))))))
 
 (defun print-time (ut &key show-date show-time (stream *standard-output*)
-                      (locale *locale*) fmt)
-  (format-time stream ut show-date show-time locale fmt)
+                      (locale *locale*) fmt time-zone)
+  (format-time stream ut show-date show-time locale fmt time-zone)
   ut)
       
 


Index: cl-l10n/tests.lisp
diff -u cl-l10n/tests.lisp:1.6 cl-l10n/tests.lisp:1.7
--- cl-l10n/tests.lisp:1.6	Wed Mar 23 11:58:16 2005
+++ cl-l10n/tests.lisp	Thu Mar 31 15:53:42 2005
@@ -8,95 +8,95 @@
 
 (rem-all-tests)
 (deftest load-locs 
-    (progn (locale "en_ZA") (locale "sv_SE") (locale "en_GB")
+         (progn (locale "en_ZA") (locale "sv_SE") (locale "en_GB")
            (locale "en_US") (locale "af_ZA") t)
-  t)
+         t)
+
 
 ;; Format number tests
 (deftest number.1
-    (format nil "~v:/cl-l10n:format-number/" "en_ZA" 1000)
-  "1,000")
+         (format nil "~v:/cl-l10n:format-number/" "en_ZA" 1000)
+         "1,000")
 
 (deftest number.2
-    (format nil "~v:@/cl-l10n:format-number/" "en_ZA" 1000)
-  "1000")
+         (format nil "~v:@/cl-l10n:format-number/" "en_ZA" 1000)
+         "1000")
 
 (deftest number.3
-    (format nil "~v/cl-l10n:format-number/" "en_ZA" 1000)
-  "1,000.00")
+         (format nil "~v/cl-l10n:format-number/" "en_ZA" 1000)
+         "1,000.00")
 
 (deftest number.4
-    (format nil "~v/cl-l10n:format-number/" "sv_SE" 1000)
-  "1 000,00")
+         (format nil "~v/cl-l10n:format-number/" "sv_SE" 1000)
+         "1 000,00")
 
 (deftest number.5
-    (format nil "~v:/cl-l10n:format-number/" "sv_SE" 1000)
-  "1 000")
+         (format nil "~v:/cl-l10n:format-number/" "sv_SE" 1000)
+         "1 000")
 
 (deftest number.6
-    (format nil "~v:/cl-l10n:format-number/" "sv_SE" 1/2)
-  "0,50")
+         (format nil "~v:/cl-l10n:format-number/" "sv_SE" 1/2)
+         "0,50")
 
 (deftest number.7
-    (format nil "~v:/cl-l10n:format-number/" "en_GB" 100.12312d0)
-  "100.12312")
+         (format nil "~v:/cl-l10n:format-number/" "en_GB" 100.12312d0)
+         "100.12312")
 
 
 ;; Money tests
 (deftest money.1
-    (format nil "~v:/cl-l10n:format-money/" "en_ZA" 1000)
-  "ZAR 1,000.00")
+         (format nil "~v:/cl-l10n:format-money/" "en_ZA" 1000)
+         "ZAR 1,000.00")
 
 
 (deftest money.2
-    (format nil "~v@/cl-l10n:format-money/" "en_ZA" 1000)
-  "R1000.00")
+         (format nil "~v@/cl-l10n:format-money/" "en_ZA" 1000)
+         "R1000.00")
 
 (deftest money.3
-    (format nil "~v:@/cl-l10n:format-money/" "en_ZA" 1000)
-  "ZAR 1000.00")
+         (format nil "~v:@/cl-l10n:format-money/" "en_ZA" 1000)
+         "ZAR 1000.00")
 
 (deftest money.4
-    (format nil "~v:/cl-l10n:format-money/" "sv_SE" 1000)
-  "1 000,00 SEK")
+         (format nil "~v:/cl-l10n:format-money/" "sv_SE" 1000)
+         "1 000,00 SEK")
 
 
 (deftest money.5
-    (format nil "~v@/cl-l10n:format-money/" "sv_SE" 1000)
-  "1000,00 kr")
+         (format nil "~v@/cl-l10n:format-money/" "sv_SE" 1000)
+         "1000,00 kr")
 
 (deftest money.6
-    (format nil "~v:@/cl-l10n:format-money/" "sv_SE" 1000)
-  "1000,00 SEK")
-
+         (format nil "~v:@/cl-l10n:format-money/" "sv_SE" 1000)
+         "1000,00 SEK")
 
 ;; Time tests
 (deftest time.1
-    (format nil "~v:@/cl-l10n:format-time/" "en_ZA" 3091103120)
-  "Sun 14 Dec 1997 17:45:20 +0200")
+         (format nil "~v,,v:@/cl-l10n:format-time/" "en_ZA" 0 3091103120)
+         "Sun 14 Dec 1997 15:45:20 +0000")
 
 (deftest time.2
-    (format nil "~v:@/cl-l10n:format-time/" "sv_SE" 3091103120)
-  "sön 14 dec 1997 17.45.20")
+         (format nil "~v,,v:@/cl-l10n:format-time/" "sv_SE" 0 3091103120)
+         "sön 14 dec 1997 15.45.20")
 
 (deftest time.3
-    (format nil "~v/cl-l10n:format-time/" "en_US" 3091103120)
-  "05:45:20 ")
+         (format nil "~v,,v/cl-l10n:format-time/" "en_US" 0 3091103120)
+         "03:45:20 ")
 
 (deftest time.4
-    (format nil "~v:/cl-l10n:format-time/" "en_US" 3091103120)
-  "12/14/1997")
+         (format nil "~v:/cl-l10n:format-time/" "en_US" 3091103120)
+         "12/14/1997")
 
 (deftest time.5
-    (format nil "~v@/cl-l10n:format-time/" "en_US" 3091103120)
-  "17:45:20 ")
+         (format nil "~v,,v@/cl-l10n:format-time/" "en_US" 0 3091103120)
+         "15:45:20 ")
 
 (deftest time.6
-    (format nil "~v@/cl-l10n:format-time/" "sv_SE" 3091103120)
-  "17.45.20")
+         (format nil "~v,,v@/cl-l10n:format-time/" "sv_SE" 0 3091103120)
+         "15.45.20")
 
 (defmacro def-time-directive-test (name directive result)
-  `(deftest ,name (format nil "~v,vU" "en_ZA" ,directive 3320556360)
+  `(deftest ,name (format nil "~v,v,vU" "en_ZA" ,directive 0 3320556360)
             ,result))
 
 (def-time-directive-test directive.1 "%%" "%")
@@ -104,7 +104,7 @@
 (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.6 "%c" "Wed 23 Mar 2005 08:46:00 +0000")
 (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")
@@ -113,11 +113,11 @@
 (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.15 "%H" "08")
+(def-time-directive-test directive.16 "%I" "08")
 (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.18 "%k" " 8")
+(def-time-directive-test directive.19 "%l" " 8")
 (def-time-directive-test directive.21 "%m" "03")
 (def-time-directive-test directive.22 "%M" "46")
 (def-time-directive-test directive.23 "%n" "
@@ -125,23 +125,23 @@
 (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.27 "%r" "08:46:00 ")
+(def-time-directive-test directive.28 "%R" "08: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.32 "%T" "08: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.39 "%X" "08: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")
+(def-time-directive-test directive.42 "%z" "+0000")
+(def-time-directive-test directive.43 "%Z" "+0000")
 
 
 
@@ -155,48 +155,111 @@
   "howareyou" "How are you")
 
 (deftest i18n.1 
-    (gettext "howareyou" *my-bundle* "en_ZA")
-  "How are you")
+         (gettext "howareyou" *my-bundle* "en_ZA")
+         "How are you")
 
 (deftest i18n.2
-    (gettext "howareyou" *my-bundle* "af_ZA")
-  "Hoe lyk it")
+         (gettext "howareyou" *my-bundle* "af_ZA")
+         "Hoe lyk it")
 
 ;; format
 (deftest format.1
-    (format nil "~v:@U" "en_ZA" 3091103120)
-  "Sun 14 Dec 1997 17:45:20 +0200")
+         (format nil "~v,,v:@U" "en_ZA" -2 3091103120)
+         "Sun 14 Dec 1997 17:45:20 +0200")
 
 (deftest format.2
-    (format nil "~v:n" "en_ZA" 1000)
-  "1,000")
+         (format nil "~v:n" "en_ZA" 1000)
+         "1,000")
 
 (deftest format.3
-    (format nil "~v:@m" "sv_SE" 1000)
-  "1000,00 SEK")
+         (format nil "~v:@m" "sv_SE" 1000)
+         "1000,00 SEK")
 
 ;; formatter
 (deftest formatter.1
-    (format nil (formatter "~v:@U") "en_ZA" 3091103120)
-  "Sun 14 Dec 1997 17:45:20 +0200")
+         (format nil (formatter "~v,,v:@U") "en_ZA" -2 3091103120)
+         "Sun 14 Dec 1997 17:45:20 +0200")
 
 (deftest formatter.2
-    (format nil (formatter "~v:n") "en_ZA" 1000)
-  "1,000")
+         (format nil (formatter "~v:n") "en_ZA" 1000)
+         "1,000")
 
 (deftest formatter.3
-    (format nil (formatter "~v:@m") "sv_SE" 1000)
-  "1000,00 SEK")
+         (format nil (formatter "~v:@m") "sv_SE" 1000)
+         "1000,00 SEK")
 
 
 ;; parse-number
 (deftest parse-number.1
-    (parse-number (format nil "~vn" "af_ZA" -1001231.5) "af_ZA")
-  -1001231.5)
+         (parse-number (format nil "~vn" "af_ZA" -1001231.5) "af_ZA")
+         -1001231.5)
 
 (deftest parse-number.2
-    (parse-number (format nil "~v@:n" "en_ZA" -1001231.5) "en_ZA")
-  -1001231.5)
+         (parse-number (format nil "~v@:n" "en_ZA" -1001231.5) "en_ZA")
+         -1001231.5)
+
+(deftest parse-number.3
+         (parse-number (format nil "~v@:n" "sv_SE" -1001231.5) "sv_SE")
+         -1001231.5)
+
+
+;; parse-time 
+(deftest parse-time.1
+         (let ((*locale* "en_ZA")
+               (time (get-universal-time)))
+           (= time (parse-time (format nil "~:U~:* ~@U" time))))
+         t)
+
+(deftest parse-time.2
+         (let ((*locale* "sv_SE")
+               (time (get-universal-time)))
+           (= time (parse-time (format nil "~:U~:* ~@U" time))))
+         t)
+
+(deftest parse-time.3
+         (let ((*locale* "en_US")
+               (time (get-universal-time)))
+           (= time (parse-time (format nil "~:U~:* ~@U" time))))
+         t)
+
+(deftest parse-time.4
+         (let ((*locale* "en_GB")
+               (time (get-universal-time)))
+           (= time (parse-time (format nil "~:U~:* ~@U" time))))
+         t)
+
+(deftest parse-time.5
+         (parse-time "05/04/03" :default-zone -2 :locale "en_ZA")
+         3258482400)
+
+(deftest parse-time.6
+         (parse-time "05/04/03" :default-zone -2  :locale "en_US")
+         3260988000)
+
+(deftest parse-time.7
+         (parse-time "05/04/03"  :default-zone -2 :locale "en_ZA")
+         3258482400)
+
+(deftest parse-time.8
+         (let ((*locale* "en_ZA")
+               (time (get-universal-time)))
+           (= time (parse-time (format nil "~:@U" time))))
+         t)
+
+(deftest parse-time.9
+         (let ((*locale* "en_US")
+               (time (get-universal-time)))
+           (= time (parse-time (format nil "~:@U" time))))
+         t)
+
+(deftest parse-time.10
+         (let ((*locale* "sv_SE")
+               (time (get-universal-time)))
+           (= time (parse-time (format nil "~:@U" time))))
+         t)
+
+
+         
 
 
 ;; EOF




More information about the Cl-l10n-cvs mailing list