Changeset 12793 in project


Ignore:
Timestamp:
12/08/08 07:06:36 (11 years ago)
Author:
Kon Lovett
Message:

Save of locale & srfi-29 refactor.

Location:
release/3/srfi-19/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • release/3/srfi-19/trunk/srfi-19-common.scm

    r12073 r12793  
    2828
    2929(define-constant MN/YR 12)
    30 
    31 ; Daylight saving time offset from standard offset.
    32 ; ("spring forward" add it, "fall back" subtract it)
    33 (define-constant DEFAULT-DST-OFFSET 3600)
    3430
    3531;;
  • release/3/srfi-19/trunk/srfi-19-core.scm

    r12745 r12793  
    282282      tm:time-difference) ) )
    283283
    284 (use srfi-6 srfi-8 srfi-9 posix
    285      numbers locale
    286      misc-extn-record)
     284(require-extension
     285  srfi-6 srfi-8 srfi-9 posix
     286  numbers locale
     287  misc-extn-record)
    287288
    288289(register-feature! 'srfi-19)
     
    10541055;;; Timezone Locale Object (Public Immutable)
    10551056
    1056 (define UNKNOWN-LOCAL-TZ-NAME "XXXX")
    1057 
    1058 (define LOCAL-TZ-NAME
    1059   (or (local-timezone-abbreviation) UNKNOWN-LOCAL-TZ-NAME))
    1060 
    10611057(define tm:make-timezone-locale cons)
    10621058
     
    10801076    (error loc "invalid timezone locale" obj) ) )
    10811077
    1082 (define make-posix-timezone
    1083   (let ([hms
    1084           (lambda (secs)
    1085             (let* ([asecs (abs secs)]
    1086                    [rsecs (remainder asecs SEC/HR)])
    1087               (string-append
    1088                 (if (negative? secs) "-" "+")
    1089                 (number->string (quotient asecs SEC/HR))
    1090                 ":" (number->string (quotient rsecs SEC/MIN))
    1091                 ":" (number->string (remainder rsecs SEC/MIN)))))])
    1092     (lambda (dst-tzn dst-off std-tzn std-off)
    1093       (string-append dst-tzn (hms dst-off) std-tzn (hms std-off)) ) ) )
    1094 
    1095 (define (make-local-timezone-locale)
    1096   ; Need local timezone info
    1097   (let* ([tv (seconds->local-time (current-seconds))]
    1098          [dstf (vector-ref tv 8)])
    1099     ; Need the current-timezone-components, and unless we
    1100     ; have a current-timezone need to fake one from system
    1101     ; time info.
    1102     (unless (current-timezone)
    1103       (let ([tzn LOCAL-TZ-NAME])
    1104         ; Set the current-timezone for future reference.
    1105         (current-timezone
    1106           (cond-expand
    1107             [macosx
    1108               ; Since the tzo reflects the dst status need to fake
    1109               ; the one not in effect.
    1110               (let ([tzo (vector-ref tv 9)])
    1111                 (if dstf
    1112                   (make-posix-timezone
    1113                     UNKNOWN-LOCAL-TZ-NAME (+ tzo DEFAULT-DST-OFFSET) tzn tzo)
    1114                   (make-posix-timezone
    1115                     tzn tzo UNKNOWN-LOCAL-TZ-NAME (- tzo DEFAULT-DST-OFFSET)) ) ) ]
    1116             [else
    1117               ; Since only the standard tzn & tzo are available need to
    1118               ; fake summer time.
    1119               (let ([tzo (vector-ref tv 9)])
    1120                 (make-posix-timezone
    1121                   tzn tzo UNKNOWN-LOCAL-TZ-NAME (- tzo DEFAULT-DST-OFFSET)) ) ] ) ) ) )
    1122     ; Return local tz info
    1123     (make-timezone-locale dstf (current-timezone-components)) ) )
     1078(define (dst-is-current)
     1079  (vector-ref (seconds->local-time (current-seconds)) 8) )
    11241080
    11251081(define local-timezone-locale
    11261082  (make-parameter
    1127     (make-local-timezone-locale)
     1083    (make-timezone-locale (dst-is-current) (current-timezone-components))
    11281084    (lambda (obj)
    11291085      (if (timezone-locale? obj)
    1130         obj
    1131         (local-timezone-locale)))) )
     1086          obj
     1087          (local-timezone-locale)))) )
    11321088
    11331089(define utc-timezone-locale
     
    11361092    (lambda (obj)
    11371093      (if (timezone-locale? obj)
    1138         obj
    1139         (utc-timezone-locale)))) )
     1094          obj
     1095          (utc-timezone-locale)))) )
    11401096
    11411097;; Returns #f or a valid tz-name
  • release/3/srfi-19/trunk/srfi-19.setup

    r12073 r12793  
    55
    66(required-extension-version
     7  'locale                 "0.4.0"
    78  'misc-extn              "3.2.0"
    8   'srfi-29                "1.5"
     9  'srfi-29                "1.14.0"
    910  'miscmacros             "2.4"
    1011  'numbers                "1.8")
Note: See TracChangeset for help on using the changeset viewer.