/[cl-l10n]/cl-l10n/parse-time.lisp
ViewVC logotype

Diff of /cl-l10n/parse-time.lisp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by sross, Thu Apr 27 18:30:30 2006 UTC revision 1.4 by alendvai, Thu Jun 8 09:38:19 2006 UTC
# Line 600  Line 600 
600      ;; patterns have not been explicitly specified so we try      ;; patterns have not been explicitly specified so we try
601      ;; to match against locale a specific date pattern first.      ;; to match against locale a specific date pattern first.
602      ;; eg. 03/04/2005 is 3rd April in UK but 4 March in US.      ;; eg. 03/04/2005 is 3rd April in UK but 4 March in US.
603      (dolist (pattern (parsers *locale*))      (dolist (pattern (parsers (current-locale)))
604        (let ((res (match-pattern pattern        (let ((res (match-pattern pattern
605                                  string-parts                                  string-parts
606                                  parts-length)))                                  parts-length)))
# Line 620  Line 620 
620                                 (default-hours nil) (default-day nil)                                 (default-hours nil) (default-day nil)
621                                 (default-month nil) (default-year nil)                                 (default-month nil) (default-year nil)
622                                 (default-zone nil) (default-weekday nil)                                 (default-zone nil) (default-weekday nil)
623                                 (locale *locale*))                                 (locale (current-locale)))
624    "Tries very hard to make sense out of the argument time-string using    "Tries very hard to make sense out of the argument time-string using
625     locale and returns a single integer representing the universal time if     locale and returns a single integer representing the universal time if
626     successful.  If not, it returns nil.  If the :error-on-mismatch     successful.  If not, it returns nil.  If the :error-on-mismatch
# Line 630  Line 630 
630     keywords can be given a numeric value or the keyword :current     keywords can be given a numeric value or the keyword :current
631     to set them to the current value.  The default-default values     to set them to the current value.  The default-default values
632     are 00:00:00 on the current date, current time-zone."     are 00:00:00 on the current date, current time-zone."
633    (let* ((*error-on-mismatch* error-on-mismatch)    (with-locale locale
634           (*locale* (locale-des->locale locale))      (let* ((*error-on-mismatch* error-on-mismatch)
635           (string-parts (decompose-string time-string :start start :end end))             (string-parts (decompose-string time-string :start start :end end))
636           (parts-length (length string-parts))             (parts-length (length string-parts))
637           (string-form (get-matching-pattern patterns string-parts parts-length)))             (string-form (get-matching-pattern patterns string-parts parts-length)))
638      (if string-form        (if string-form
639          (let ((parsed-values (make-default-time default-seconds default-minutes            (let ((parsed-values (make-default-time default-seconds default-minutes
640                                                  default-hours default-day                                                    default-hours default-day
641                                                  default-month default-year                                                    default-month default-year
642                                                  default-zone default-weekday)))                                                    default-zone default-weekday)))
643            (set-time-values string-form parsed-values)              (set-time-values string-form parsed-values)
644            (convert-to-unitime parsed-values))              (convert-to-unitime parsed-values))
645          (if *error-on-mismatch*            (if *error-on-mismatch*
646              (error 'parser-error :value time-string :reason "Not a recognized time/date format.")                (error 'parser-error :value time-string :reason "Not a recognized time/date format.")
647            nil))))                nil)))))
648    
649    
650  ; EOF  ; EOF

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.5