#| -*-Scheme-*-
-$Id: datime.scm,v 14.10 1995/04/23 03:19:48 cph Exp $
+$Id: datime.scm,v 14.11 1995/04/23 05:43:43 cph Exp $
Copyright (c) 1988-95 Massachusetts Institute of Technology
((ucode-primitive decode-time 2) dt ((ucode-primitive encode-time 1) dt))
dt))
-(define (month/max-days month)
- (guarantee-month month 'MONTH/MAX-DAYS)
- (vector-ref '#(31 29 31 30 31 30 31 31 30 31 30 31) (- month 1)))
-
-(define (month/short-string month)
- (guarantee-month month 'MONTH/SHORT-STRING)
- (vector-ref '#("Jan" "Feb" "Mar" "Apr" "May" "Jun"
- "Jul" "Aug" "Sep" "Oct" "Nov" "Dec")
- (- month 1)))
-
-(define (month/long-string month)
- (guarantee-month month 'MONTH/LONG-STRING)
- (vector-ref '#("January" "February" "March" "April" "May" "June"
- "July" "August" "September" "October"
- "November" "December")
- (- month 1)))
-
-(define (guarantee-month month name)
- (if (not (exact-integer? month))
- (error:wrong-type-argument month "month integer" name))
- (if (not (<= 1 month 12))
- (error:bad-range-argument month name)))
-\f
(define (decode-universal-time time)
(let ((result (allocate-decoded-time)))
((ucode-primitive decode-time 2) result time)
(define (get-decoded-time)
(decode-universal-time (get-universal-time)))
+(define (time-zone? object)
+ (and (number? object)
+ (exact? object)
+ (<= -24 object 24)
+ (integer? (* 3600 object))))
+
+(define (decoded-time/daylight-savings-time? dt)
+ (> (decoded-time/daylight-savings-time dt) 0))
+\f
(define (decoded-time/date-string time)
- (string-append
- (if (decoded-time/day-of-week time)
- (string-append
- (vector-ref '#("Monday" "Tuesday" "Wednesday" "Thursday" "Friday"
- "Saturday" "Sunday")
- (decoded-time/day-of-week time))
- " ")
- "")
- (month/long-string (decoded-time/month time))
- " "
- (number->string (decoded-time/day time))
- ", "
- (number->string (decoded-time/year time))))
+ (string-append (weekday/long-string (decoded-time/day-of-week time))
+ " "
+ (month/long-string (decoded-time/month time))
+ " "
+ (number->string (decoded-time/day time))
+ ", "
+ (number->string (decoded-time/year time))))
(define (decoded-time/time-string time)
(let ((second (decoded-time/second time))
" "
(if (< hour 12) "AM" "PM"))))
-(define (time-zone? object)
- (and (number? object)
- (exact? object)
- (<= -24 object 24)
- (integer? (* 3600 object))))
-
(define (time-zone->string tz)
(if (not (time-zone? tz))
(error:wrong-type-argument tz "time zone" 'TIME-ZONE->STRING))
(d2 (integer-divide-quotient qr))
(d2 (integer-divide-remainder qr))))))
-(define (decoded-time/daylight-savings-time? dt)
- (> (decoded-time/daylight-savings-time dt) 0))
\ No newline at end of file
+(define (month/max-days month)
+ (guarantee-month month 'MONTH/MAX-DAYS)
+ (vector-ref '#(31 29 31 30 31 30 31 31 30 31 30 31) (- month 1)))
+
+(define (month/short-string month)
+ (guarantee-month month 'MONTH/SHORT-STRING)
+ (vector-ref '#("Jan" "Feb" "Mar" "Apr" "May" "Jun"
+ "Jul" "Aug" "Sep" "Oct" "Nov" "Dec")
+ (- month 1)))
+
+(define (month/long-string month)
+ (guarantee-month month 'MONTH/LONG-STRING)
+ (vector-ref '#("January" "February" "March" "April" "May" "June"
+ "July" "August" "September" "October"
+ "November" "December")
+ (- month 1)))
+
+(define (guarantee-month month name)
+ (if (not (exact-integer? month))
+ (error:wrong-type-argument month "month integer" name))
+ (if (not (<= 1 month 12))
+ (error:bad-range-argument month name)))
+
+(define (day-of-week/short-string day)
+ (guarantee-day-of-week day 'DAY-OF-WEEK/SHORT-STRING)
+ (vector-ref '#("Mon" "Tue" "Wed" "Thu" "Fri" "Sat" "Sun") day-of-week))
+
+(define (day-of-week/long-string day)
+ (guarantee-day-of-week day 'DAY-OF-WEEK/LONG-STRING)
+ (vector-ref '#("Monday" "Tuesday" "Wednesday" "Thursday" "Friday"
+ "Saturday" "Sunday")
+ day-of-week))
+
+(define (guarantee-day-of-week day name)
+ (if (not (exact-integer? day))
+ (error:wrong-type-argument day "day-of-week integer" name))
+ (if (not (<= 0 day 6))
+ (error:bad-range-argument day name)))
\ No newline at end of file