Changeset 38125 in project


Ignore:
Timestamp:
01/16/20 02:54:04 (5 weeks ago)
Author:
Kon Lovett
Message:

expose make-timezone-locale, check- routines return their object, use locale provided tz offset predicate

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/5/srfi-19/trunk/srfi-19-timezone.scm

    r38082 r38125  
    11;;;;srfi-19-timezone.scm
     2
     3;;Issues
     4;;
     5;; - internal -/+ meaning vs external ISO 8601 +/- meaning
    26
    37(module srfi-19-timezone
     
    610  local-timezone-locale
    711  utc-timezone-locale
    8   #;make-timezone-locale
     12  make-timezone-locale
    913  timezone-locale-name
    1014  timezone-locale-offset
     
    2428(import type-checks)
    2529(import type-errors)
     30
     31;;;
     32
     33(include "srfi-19-common")
    2634
    2735;;;Timezone Locale Object (Public Immutable, but not enforced)
     
    5664;;
    5765
     66;delay initializing `local-timezone-locale'
    5867(define (local-timezone-locale*)
    5968  (or
     
    6574;;
    6675
    67 #;;Unusued
     76;converts external ISO 8601 +/- meaning to internal -/+ meaning
    6877(define (make-timezone-locale nam off dst?)
    6978  (update-timezone-components! (make-timezone-components #f "SRFI 19")
     
    7382
    7483(define (timezone-locale-name . tzc)
    75   (let ((tzc (optional tzc (local-timezone-locale*))))
    76     (check-timezone-components 'timezone-locale-name tzc)
    77     (let ((tzn (timezone-components-ref/dst? tzc 'dst-name 'std-name)))
    78       ;TZ may not be set
    79       (and
    80         (not (unknown-timezone-name? tzn))
    81         tzn ) ) ) )
     84  (let (
     85    (tzc
     86      (check-timezone-components 'timezone-locale-name
     87        (optional tzc (local-timezone-locale*))))
     88    (tzn (timezone-components-ref/dst? tzc 'dst-name 'std-name)) )
     89    ;TZ may not be set
     90    (and
     91      (not (unknown-timezone-name? tzn))
     92      tzn ) ) )
    8293
     94;converts internal -/+ meaning to external ISO 8601 +/- meaning
    8395(define (timezone-locale-offset . tzc)
    84   (let ((tzc (optional tzc (local-timezone-locale*))))
    85     (check-timezone-components 'timezone-locale-offset tzc)
    86     (let ((tzo (timezone-components-ref/dst? tzc 'dst-offset 'std-offset)))
    87       ;TZ may not be set but if it is then convert to ISO 8601
    88       (if tzo (- tzo)
    89           0 ) ) ) )
     96  (let* (
     97    (tzc
     98      (check-timezone-components 'timezone-locale-offset
     99        (optional tzc (local-timezone-locale*))))
     100    (tzo
     101      (timezone-components-ref/dst? tzc 'dst-offset 'std-offset)) )
     102    ;TZ may not be set but if it is then convert to ISO 8601
     103    (if (not tzo) 0 (- tzo)) ) )
    90104
    91105(define (timezone-locale-dst? . tzc)
    92   (let ((tzc (optional tzc (local-timezone-locale*))))
    93     (check-timezone-components 'timezone-locale-offset tzc)
    94     (timezone-component-ref tzc 'dst?) ) )
     106  (timezone-component-ref
     107    (check-timezone-components 'timezone-locale-offset
     108      (optional tzc (local-timezone-locale*)))
     109    'dst?) )
    95110
    96111;;
     
    109124    ((boolean? tzi)               (local-timezone-locale*))
    110125    ((timezone-components? tzi)   tzi)
    111     ((fixnum? tzi)                tzi)
     126    ((timezone-offset? tzi)       tzi)
    112127    (else
    113128      (error-timezone-info loc tzi)) ) )
Note: See TracChangeset for help on using the changeset viewer.