(module test-data mzscheme
(require (lib "contract.ss")
(lib "pregexp.ss")
(lib "time.ss" "srfi" "19"))
(require (file "base.ss")
(file "era.ss")
(file "persistent-struct.ss")
(file "type.ss"))
(provide-persistent-struct course
((code type:symbol)
(name type:text)
(value type:integer)
(rating type:real)
(active type:boolean)
(start type:time-tai)))
(provide-persistent-struct programme
((code type:symbol)
(name type:text)))
(provide-persistent-struct programme-structure
((course-code type:symbol)
(programme-code type:symbol)
(year type:integer)
(compulsory type:boolean)))
(provide time1
time2
time3
unstored-course
stored-course
unstored-programme-structure
stored-programme-structure)
(define (yyyy-mm-dd-hh-mm-ss-string? str)
(and (string? str)
(pregexp-match "[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}" str)))
(provide/contract
(string->time-tai (-> yyyy-mm-dd-hh-mm-ss-string? time?))
(string->time-utc (-> yyyy-mm-dd-hh-mm-ss-string? time?)))
(define-persistent-struct course
((code type:symbol)
(name type:text)
(value type:integer)
(rating type:real)
(active type:boolean)
(start type:time-tai)))
(define-persistent-struct programme
((code type:symbol)
(name type:text))
())
(define-persistent-struct programme-structure
((course-code type:symbol)
(programme-code type:symbol)
(year type:integer)
(compulsory type:boolean)))
(define (string->time-tai str)
(date->time-tai (string->date (string-append str "+0000") "~Y-~m-~d ~H:~M:~S~z")))
(define (string->time-utc str)
(date->time-utc (string->date (string-append str "+0000") "~Y-~m-~d ~H:~M:~S~z")))
(define time1 (string->time-tai "2001-01-01 01:01:01"))
(define time2 (string->time-tai "2002-02-02 02:02:02"))
(define time3 (string->time-tai "9999-01-01 01:01:01"))
(define unstored-course
(make-course 'SBS-101 "Biology 101" 2 2.5 #t time1))
(define stored-course
(let ([course (make-course 'SBS-101 "Biology 101" 2 2.5 #t time2)])
(set-id! course 0)
(set-revision! course 1000)
course))
(define unstored-programme-structure
(make-programme-structure 'SBS-101 'BIO1 1 #t))
(define stored-programme-structure
(let ([structure (make-programme-structure 'SBS-101 'BIO1 1 #t)])
(set-id! structure 0)
(set-revision! structure 1000)
structure))
)