plt.ss
#lang scheme/base
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; DATE.plt
;;
;; date-specific routines.  Reexports srfi/19
;;
;; Bonzai Lab, LLC.  All rights reserved.
;;
;; Licensed under LGPL.
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; plt.ss - provide plt date bindings for all exported date.plt objects
;; yc 10/7/2009 - first version - including binding for srfi/19
;; yc 10/17/2009 - adding rfc822.ss & adding day>? family...
;; yc 1/19/2010 - added conversion of date->string & string->date.  fix rfc822->date to read-rfc822
;; yc 7/6/2010 - added iso8601.ss
(require (prefix-in s: "srfi.ss")
         "convert.ss"
         (rename-in (only-in "date.ss" current-local-tz-offset)
                    (current-local-tz-offset offset))
         (only-in "depend.ss" provide/strip-prefix 
                  provide/contract ->)
         scheme/contract
         (for-syntax scheme/base)
         )

;; once this is moved to require.ss it does not work!! why?

(define-plt-date* 
  ;; srfi/19
  (current-date (tz (offset)))
  (date->julian-day #:any! (d :date))
  (date->modified-julian-day #:any! (d :date))
  (julian-day->date jd)
  (modified-julian-day->date mjd)
  (date->time-monotonic #:any! (d :date))
  (date->time-tai #:any! (d :date))
  (date->time-utc #:any! (d :date))
  (time-monotonic->date t (tz (offset)))
  (time-tai->date t (tz (offset)))
  (time-utc->date t (tz (offset))) 
  ;; date->string & string->date are not provided
  (date->string #:any! (d :date) (format "~c"))
  (string->date str template)
  ;; date.ss
  (build-date y m d (hh 0) (mm 0) (ss 0) (nano 0) #:tz (tz 0))
  (date+ (date :date) days)
  (date- #:any! (d1 :date) (d2 :date))
  (date>? #:any! (d1 :date) (d2 :date) #:rest (dates :date))
  (date<? #:any! (d1 :date) (d2 :date) #:rest (dates :date))
  (date=? #:any! (d1 :date) (d2 :date) #:rest (dates :date))
  (date>=? #:any! (d1 :date) (d2 :date) #:rest (dates :date))
  (date<=? #:any! (d1 :date) (d2 :date) #:rest (dates :date))
  (date!=? #:any! (d1 :date) (d2 :date) #:rest (dates :date))
  (day>? #:any! (d1 :date) (d2 :date) #:rest (dates :date))
  (day<? #:any! (d1 :date) (d2 :date) #:rest (dates :date))
  (day=? #:any! (d1 :date) (d2 :date) #:rest (dates :date))
  (day>=? #:any! (d1 :date) (d2 :date) #:rest (dates :date))
  (day<=? #:any! (d1 :date) (d2 :date) #:rest (dates :date))
  (day!=? #:any! (d1 :date) (d2 :date) #:rest (dates :date))
  (date===? #:any! (d1 :date) (d2 :date) #:rest (dates :date))
  (date->seconds #:any! (d :date))
  (date->alarm #:any! (d :date))
  (date->future-alarm #:any! (d :date))
  ;; rfc822.ss
  (read-rfc822 s)
  (date->rfc822 #:any! (d :date))
  ;; iso8601.ss
  (read-iso8601 s) 
  (date->iso8601 #:any! (d :date))
  ;; week.ss
  (nth-week-day y m wday nth (hh 0) (mm 0) (ss 0) #:tz (tz 0))
  (week-day>=mday y m wday mday (hh 0) (mm 0) (ss 0) #:tz (tz 0))
  (week-day>mday y m wday mday (hh 0) (mm 0) (ss 0) #:tz (tz 0))
  (week-day<=mday y m wday mday (hh 0) (mm 0) (ss 0) #:tz (tz 0))
  (week-day<mday y m wday mday (hh 0) (mm 0) (ss 0) #:tz (tz 0))
  )
;; #|
(provide/strip-prefix s:
                      ;; srfi/19
                      time-duration
                      time-monotonic
                      time-process
                      time-tai
                      time-thread
                      time-utc
                      time?
                      make-time
                      time-type
                      time-nanosecond
                      time-second
                      time-resolution
                      set-time-type!
                      set-time-second!
                      set-time-nanosecond!
                      copy-time
                      time<=?
                      time<?
                      time=?
                      time>=?
                      time>?
                      time-difference
                      time-difference!
                      add-duration
                      add-duration!
                      subtract-duration
                      subtract-duration!
                      julian-day->time-monotonic
                      julian-day->time-tai
                      julian-day->time-utc
                      modified-julian-day->time-monotonic
                      modified-julian-day->time-tai
                      modified-julian-day->time-utc
                      time-monotonic->julian-day
                      time-monotonic->modified-julian-day
                      time-monotonic->time-tai
                      time-monotonic->time-tai!
                      time-monotonic->time-utc
                      time-monotonic->time-utc!
                      time-tai->julian-day
                      time-tai->modified-julian-day
                      time-tai->time-monotonic
                      time-tai->time-utc
                      time-tai->time-monotonic!
                      time-tai->time-utc!
                      time-utc->julian-day
                      time-utc->modified-julian-day
                      time-utc->time-monotonic
                      time-utc->time-tai
                      time-utc->time-monotonic!
                      time-utc->time-tai!
                      ;; base.ss
                      leap-year?
                      week-day
                      year-day
                      normalize-year/month/day
                      month->num
                      weekday->num
                      ;; date.ss
                      current-local-tz-offset
                      date-comp-type
                      )
;;|#
(define (date-nanosecond d) 0)

(provide/contract 
 (date-nanosecond (-> date? number?)))

(provide (rename-out (date-time-zone-offset date-zone-offset)))