Changeset 15661 in project


Ignore:
Timestamp:
08/31/09 00:41:15 (10 years ago)
Author:
Kon Lovett
Message:

Save.

Location:
release/4/locale/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/4/locale/trunk/locale-posix.scm

    r15643 r15661  
    6868
    6969(define parse-posix-literal-timezone
    70         (let ((name-re (regexp "^([A-Za-z]+)" #;"^([A-Za-z]+)|<([^>]+)>"))
     70        (let ((name-re (regexp "(^[A-Za-z]+)|^<([^>]+)>"))
    7171                                (offset-re (regexp "^(\\+|-)?([0-9]+)(:[0-9]+)?(:[0-9]+)?"))
    7272                                ; For compatibility with System V Release 3.1, a semicolon (`;') may be
    7373                                ; used to separate the rule from the rest of the specification.
    7474                                ; Allow it to separate the "to DST" & "from DST" segments since no harm, no foul.
    75                                 (date-re (regexp "^[;,](M|J)?([0-9]+)(\\.[0-9]+)?(\\.[0-9]+)?"))
     75                                (date-re (regexp "^[;,]([JM]?)([0-9]+)(\\.[0-9]+)?(\\.[0-9]+)?"))
    7676                                (time-re (regexp "^/([0-9]+)(:[0-9]+)?(:[0-9]+)?"))
    7777                                (+0200hrs+ (* 2 SEC/HR)) )
     
    8484            (next-match
    8585              (lambda (re)
    86 (print "@ " (substring str strpos))
    8786                (and-let* ((ml (string-search re str strpos)))
    88 (print "! " ml)
    8987                  (set! strpos (+ strpos (string-length (car ml))))
    9088                  ml ) ) )
     
    9795                (cond ((not numstr) 0 )
    9896                      ((char-numeric? (string-ref numstr 0)) (string->number numstr) )
    99                       (else (failwarn "bad Posix timezone number") ) ) ) )
     97                      (else
     98                        (failwarn "bad Posix timezone number") ) ) ) )
    10099            (parse-delmcomp
    101100              (lambda (numstr delm)
     
    139138                  ; Time component is optional & defaults to 02:00:00
    140139                  (let* ((t-m (next-match time-re))
    141                          (off (if t-m (hms->offset "" (cdr t-m)) +0200hrs+)) )
     140                         (off (if t-m (hms->offset #f (cdr t-m)) +0200hrs+)) )
    142141                    (set-timezone-component! tz key (decode-dst-rule (cadr d-m) (cddr d-m) off))
    143142                    #t ) ) ) )
  • release/4/locale/trunk/tests/run.scm

    r15643 r15661  
    88        (test-group "Posix Timezone"
    99
     10    (test-assert "F1" (not (posix-timezone-string->timezone-components ":foo,bar,baz")))
     11    (test-assert "F2" (not (posix-timezone-string->timezone-components "23,foo")))
     12    (test-assert "F3" (not (posix-timezone-string->timezone-components "foo/23")))
     13    (test-assert "F4" (not (posix-timezone-string->timezone-components "foo-23bar/23")))
     14    (test-assert "F5" (not (posix-timezone-string->timezone-components "foo-23bar-22/23")))
     15
    1016          (let ((tz0 (make-timezone-components "PST+8:00" "TEST"))
    1117          (tz1 (make-timezone-components "PST+8:00PDT+7:00:00" '("POSIX" "TZ")))
     
    1521        (update-timezone-components! tz0
    1622          'std-name "PST" 'std-offset (* 8 60 60)))
     23      (test "S1" tz0
     24        (posix-timezone-string->timezone-components "PST+8:00" "TEST"))
     25
    1726      (set! tz1
    1827        (update-timezone-components! tz1
     
    2130          'dst-start (make-timezone-dst-rule-mwd 4 1 0 3600)
    2231          'dst-end (make-timezone-dst-rule-mwd 10 5 0 3600)))
     32      (test "S2" tz1
     33        (posix-timezone-string->timezone-components "PST+8:00PDT+7:00:00,M4.1.0,M10.5" '("POSIX" "TZ")))
     34
    2335      (set! tz2
    2436        (update-timezone-components! tz2
     
    2739          'dst-start (make-timezone-dst-rule-julian-noleap 23 (+ (* 12 60 60) (* 34 60)))
    2840          'dst-end (make-timezone-dst-rule-julian-leap 34 (+ (* 1 60 60) 1))))
    29 
    30       (test-assert "F1" (not (posix-timezone-string->timezone-components ":foo,bar,baz")))
    31       (test-assert "F2" (not (posix-timezone-string->timezone-components "23,foo")))
    32       (test-assert "F3" (not (posix-timezone-string->timezone-components "foo/23")))
    33       (test-assert "F4" (not (posix-timezone-string->timezone-components "foo-23bar/23")))
    34       (test-assert "F5" (not (posix-timezone-string->timezone-components "foo-23bar-22/23")))
    35 
    36       (test "S1" tz0
    37         (posix-timezone-string->timezone-components "PST+8:00" "TEST"))
    38       (test "S2" tz1
    39         (posix-timezone-string->timezone-components "PST+8:00PDT+7:00:00" '("POSIX" "TZ")))
    4041      (test "S3" tz2
    4142        (posix-timezone-string->timezone-components "PST+8:00PDT7,J23/12:34,34/1:00:01" "TEST"))
    4243
    43       (setenv "TZ" "PST+8:00PDT+7:00:00")
     44      (setenv "TZ" "PST+8:00PDT+7:00:00,M4.1.0,M10.5")
    4445      (posix-load-timezone)
    4546      (test "S4" tz1 (current-timezone-components)) )
Note: See TracChangeset for help on using the changeset viewer.