Changeset 38277 in project


Ignore:
Timestamp:
03/16/20 06:28:20 (3 weeks ago)
Author:
Kon Lovett
Message:

define struct printers in desired module, force desired module for struct tags (date-timezone-info TODO)

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

Legend:

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

    r38275 r38277  
    649649    (list-index (cut eq? b <>) +date-key-lexographic-order+)) )
    650650
     651;;
     652
     653(import (only (chicken read-syntax) define-reader-ctor))
     654(import (only (chicken format) format))
     655
     656(define-constant DATE-FORMAT-SRFI-10 "#,(srfi-19-date ~A ~A ~A ~A ~A ~A ~A ~A ~A ~A ~A ~A ~A)")
     657(define-constant DATE-FORMAT-BRACKET "#<srfi-19-date ~A ~A ~A ~A ~A ~A ~A ~A ~A ~A ~A ~A ~A>")
     658
     659(define date-record-printer-format (make-parameter 'SRFI-10
     660  (lambda (x)
     661    (if (or (not x) (eq? 'srfi-10 x) (eq? 'SRFI-10 x))
     662      x
     663      (begin
     664        (warning 'date-record-printer-format "invalid format" x)
     665        (date-record-printer-format) ) ) ) ) )
     666
     667(define (date-record-printer-format-string)
     668  (case (date-record-printer-format)
     669    ((srfi-10 SRFI-10)
     670      DATE-FORMAT-SRFI-10 )
     671    (else
     672      DATE-FORMAT-BRACKET ) ) )
     673
     674(define-record-printer (srfi-19-date dat out)
     675  (format out (date-record-printer-format-string)
     676   (%date-nanosecond dat)
     677   (%date-second dat) (%date-minute dat) (%date-hour dat)
     678   (%date-day dat) (%date-month dat) (%date-year dat)
     679   (%date-zone-offset dat)
     680   (%date-zone-name dat) (%date-dst? dat)
     681   (%date-wday dat) (%date-yday dat) (%date-jday dat)) )
     682
     683(define-reader-ctor 'srfi-19-date
     684  (lambda (ns sec min hr dy mn yr tzo tzn dstf wdy ydy jdy)
     685    (%make-date ns sec min hr dy mn yr tzo tzn dstf wdy ydy jdy)))
     686
    651687) ;module srfi-19-date
  • release/5/srfi-19/trunk/srfi-19-support.scm

    r38270 r38277  
    7878  week-day? check-week-day error-week-day
    7979  julian-day? check-julian-day error-julian-day
    80   time-record-printer-format
    81   date-record-printer-format
    8280  check-raw-seconds
    8381  check-raw-milliseconds
     
    131129;;
    132130
    133 (define-constant TIME-FORMAT-SRFI-10 "#,(srfi-19-time ~A ~A ~A)")
    134 (define-constant TIME-FORMAT-BRACKET "#<srfi-19-time ~A ~A ~A>")
    135 
    136 (define time-record-printer-format (make-parameter 'SRFI-10
    137   (lambda (x)
    138     (if (or (not x) (eq? 'srfi-10 x) (eq? 'SRFI-10 x))
    139       x
    140       (begin
    141         (warning 'time-record-printer-format "invalid format" x)
    142         (time-record-printer-format) ) ) ) ) )
    143 
    144 (define (time-record-printer-format-string)
    145   (case (time-record-printer-format)
    146     ((srfi-10 SRFI-10)
    147       TIME-FORMAT-SRFI-10 )
    148     (else
    149       TIME-FORMAT-BRACKET ) ) )
    150 
    151 (define-record-printer (srfi-19-time tim out)
    152   (format out (time-record-printer-format-string)
    153     (%time-type tim)
    154     (%time-nanosecond tim)
    155     (%time-second tim)) )
    156 
    157 ;SRFI-10
    158 (define-reader-ctor 'srfi-19-time
    159   (lambda (tt ns sec)
    160     (%make-time tt ns sec)))
    161 
    162 ;;
    163 
    164131(define (time-type? obj)
    165132  (memq obj '(monotonic utc tai gc duration process thread)) )
     
    226193(define (date? obj)
    227194  (%date? obj) )
    228 
    229 ;;
    230 
    231 (define-constant DATE-FORMAT-SRFI-10 "#,(srfi-19-date ~A ~A ~A ~A ~A ~A ~A ~A ~A ~A ~A ~A ~A)")
    232 (define-constant DATE-FORMAT-BRACKET "#<srfi-19-date ~A ~A ~A ~A ~A ~A ~A ~A ~A ~A ~A ~A ~A>")
    233 
    234 (define date-record-printer-format (make-parameter 'SRFI-10
    235   (lambda (x)
    236     (if (or (not x) (eq? 'srfi-10 x) (eq? 'SRFI-10 x))
    237       x
    238       (begin
    239         (warning 'date-record-printer-format "invalid format" x)
    240         (date-record-printer-format) ) ) ) ) )
    241 
    242 (define (date-record-printer-format-string)
    243   (case (date-record-printer-format)
    244     ((srfi-10 SRFI-10)
    245       DATE-FORMAT-SRFI-10 )
    246     (else
    247       DATE-FORMAT-BRACKET ) ) )
    248 
    249 (define-record-printer (srfi-19-date dat out)
    250   (format out (date-record-printer-format-string)
    251    (%date-nanosecond dat)
    252    (%date-second dat) (%date-minute dat) (%date-hour dat)
    253    (%date-day dat) (%date-month dat) (%date-year dat)
    254    (%date-zone-offset dat)
    255    (%date-zone-name dat) (%date-dst? dat)
    256    (%date-wday dat) (%date-yday dat) (%date-jday dat)) )
    257 
    258 (define-reader-ctor 'srfi-19-date
    259   (lambda (ns sec min hr dy mn yr tzo tzn dstf wdy ydy jdy)
    260     (%make-date ns sec min hr dy mn yr tzo tzn dstf wdy ydy jdy)))
    261195
    262196;;
  • release/5/srfi-19/trunk/srfi-19-time.scm

    r38153 r38277  
    437437  (tm:time-monotonic->time-tai tim tim) )
    438438
     439;;
     440
     441(import (only (chicken read-syntax) define-reader-ctor))
     442(import (only (chicken format) format))
     443
     444(define-constant TIME-FORMAT-SRFI-10 "#,(srfi-19-time ~A ~A ~A)")
     445(define-constant TIME-FORMAT-BRACKET "#<srfi-19-time ~A ~A ~A>")
     446
     447(define time-record-printer-format (make-parameter 'SRFI-10
     448  (lambda (x)
     449    (if (or (not x) (eq? 'srfi-10 x) (eq? 'SRFI-10 x))
     450      x
     451      (begin
     452        (warning 'time-record-printer-format "invalid format" x)
     453        (time-record-printer-format) ) ) ) ) )
     454
     455(define (time-record-printer-format-string)
     456  (case (time-record-printer-format)
     457    ((srfi-10 SRFI-10)
     458      TIME-FORMAT-SRFI-10 )
     459    (else
     460      TIME-FORMAT-BRACKET ) ) )
     461
     462(define-record-printer (srfi-19-time tim out)
     463  (format out (time-record-printer-format-string)
     464    (%time-type tim)
     465    (%time-nanosecond tim)
     466    (%time-second tim)) )
     467
     468;SRFI-10
     469(define-reader-ctor 'srfi-19-time
     470  (lambda (tt ns sec)
     471    (%make-time tt ns sec)))
     472
    439473) ;module srfi-19-time
  • release/5/srfi-19/trunk/srfi-19-tm.scm

    r38275 r38277  
    3838;;
    3939;; - The Private API but must be visible because of exported syntax
     40;;
     41;; - Forces module component of global time/date struct identifiers
    4042
    4143;; Bugs
     
    503505
    504506;#| ;dependency
    505 (define-constant srfi-19-time 'srfi-19-time)
     507(define-constant srfi-19-time 'srfi-19-time#srfi-19-time)
    506508(define-record-type-variant srfi-19-time (unchecked #;inline unsafe)
    507509  (%make-time tt ns sec)
     
    942944
    943945;#| ;dependency
    944 (define-constant srfi-19-date 'srfi-19-date)
     946(define-constant srfi-19-date 'srfi-19-date#srfi-19-date)
    945947(define-record-type-variant srfi-19-date (unchecked #;inline unsafe)
    946948  (%make-date ns sec min hr dy mn yr tzo tzn dstf wdy ydy jdy)
  • release/5/srfi-19/trunk/srfi-19.egg

    r38271 r38277  
    22
    33((synopsis "Time Data Types and Procedures")
    4  (version "4.3.0")
     4 (version "4.3.1")
    55 (category data)
    66 (author "Will Fitzgerald (for Chicken by [[/users/kon-lovett]])")
Note: See TracChangeset for help on using the changeset viewer.