#| -*-Scheme-*-
-$Id: datime.scm,v 14.44 2008/01/30 20:02:29 cph Exp $
+$Id: datime.scm,v 14.45 2008/08/25 08:37:32 cph Exp $
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
(define (universal-time->global-time-string time)
(decoded-time->string (universal-time->global-decoded-time time)))
+(define (universal-time->http-string time)
+ (decoded-time->http-string (universal-time->global-decoded-time time)))
+
(define (file-time->local-time-string time)
(decoded-time->string (file-time->local-decoded-time time)))
(define (file-time->global-time-string time)
(decoded-time->string (file-time->global-decoded-time time)))
-(define (decoded-time->string dt)
+(define (file-time->http-string time)
+ (decoded-time->http-string (file-time->global-decoded-time time)))
+
+(define (decoded-time->string dt) (%decoded-time->string dt #f))
+(define (decoded-time->http-string dt) (%decoded-time->string dt #t))
+
+(define (%decoded-time->string dt http?)
;; The returned string is in the format specified by RFC 822,
;; "Standard for the Format of ARPA Internet Text Messages",
;; provided that time-zone information is available from the C
(d2 (decoded-time/minute dt))
":"
(d2 (decoded-time/second dt))
- (let ((zone (decoded-time/zone dt)))
- (if zone
- (string-append
- " "
- (time-zone->string
- (if (decoded-time/daylight-savings-time? dt)
- (- zone 1)
- zone)))
- ""))))
+ (if http?
+ " GMT"
+ (let ((zone (decoded-time/zone dt)))
+ (if zone
+ (string-append
+ " "
+ (time-zone->string
+ (if (decoded-time/daylight-savings-time? dt)
+ (- zone 1)
+ zone)))
+ "")))))
\f
(define (string->decoded-time string)
;; STRING must be in RFC-822 format.
;;; support either truncation or expansion. On output, it uses a
;;; single format.
-(define (iso8601-string->decoded-time string)
- (let ((v (parse-8601-date/time (string->parser-buffer string))))
+(define (iso8601-string->decoded-time string #!optional start end)
+ (let ((v (*parse-string parser:iso8601-date/time string start end)))
(if (not v)
(error:bad-range-argument string 'ISO8601-STRING->DECODED-TIME))
(vector-ref v 0)))
(d2 (decoded-time/month dt))
"-"
(d2 (decoded-time/day dt))
- "T"
+ (if iso8601-separate-with-t? "T" " ")
(d2 (decoded-time/hour dt))
":"
(d2 (decoded-time/minute dt))
zone))
""))))
+(define iso8601-separate-with-t? #t)
+
(define (universal-time->local-iso8601-string time)
(decoded-time->iso8601-string (universal-time->local-decoded-time time)))
(define (iso8601-string->file-time string)
(decoded-time->file-time (iso8601-string->decoded-time string)))
\f
-(define parse-8601-date/time
+(define parser:iso8601-date/time
(*parser
(encapsulate
(lambda (v)
#| -*-Scheme-*-
-$Id: runtime.pkg,v 14.660 2008/08/24 07:20:11 cph Exp $
+$Id: runtime.pkg,v 14.661 2008/08/25 08:37:35 cph Exp $
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
day-of-week/short-string
decode-universal-time
decoded-time->ctime-string
+ decoded-time->http-string
decoded-time->iso8601-string
decoded-time->string
decoded-time->universal-time
file-time->global-ctime-string
file-time->global-iso8601-string
file-time->global-time-string
+ file-time->http-string
file-time->local-ctime-string
file-time->local-iso8601-string
file-time->local-time-string
get-decoded-time
get-universal-time
global-decoded-time
+ iso8601-separate-with-t?
iso8601-string->decoded-time
iso8601-string->file-time
iso8601-string->universal-time
month/long-string
month/max-days
month/short-string
+ parser:iso8601-date/time
string->day-of-week
string->decoded-time
string->file-time
universal-time->global-decoded-time
universal-time->global-iso8601-string
universal-time->global-time-string
+ universal-time->http-string
universal-time->local-ctime-string
universal-time->local-decoded-time
universal-time->local-iso8601-string