diff options
Diffstat (limited to '')
-rw-r--r-- | tests/unit/datetime/datetime.scm (renamed from tests/test/datetime.scm) | 212 | ||||
-rw-r--r-- | tests/unit/datetime/timespec.scm | 98 | ||||
-rw-r--r-- | tests/unit/datetime/tz.scm (renamed from tests/test/tz.scm) | 13 | ||||
-rw-r--r-- | tests/unit/datetime/zic.scm (renamed from tests/test/zic.scm) | 134 |
4 files changed, 280 insertions, 177 deletions
diff --git a/tests/test/datetime.scm b/tests/unit/datetime/datetime.scm index f73a0ad2..9f32d4a1 100644 --- a/tests/test/datetime.scm +++ b/tests/unit/datetime/datetime.scm @@ -362,22 +362,22 @@ (test-equal "Datetime->unix-time" - 1656005146 (datetime->unix-time #2022-06-23T17:25:46Z)) + 1656005146 (datetime->unix-time (datetime year: 2022 month: 06 day: 23 hour: 17 minute: 25 second: 46 tz: "UTC"))) (test-equal "Datetime->unix-time before epoch" -62167219200 - (datetime->unix-time #0000-01-01T00:00:00Z)) + (datetime->unix-time (datetime year: 0000 month: 01 day: 01 hour: 00 minute: 00 second: 00 tz: "UTC"))) -(test-equal "unix-time->datetime" #2020-09-13T12:26:40Z +(test-equal "unix-time->datetime" (datetime year: 2020 month: 09 day: 13 hour: 12 minute: 26 second: 40 tz: "UTC") (unix-time->datetime 1600000000)) -(test-equal "unix-time->datetime on epoch" #1970-01-01T00:00:00Z +(test-equal "unix-time->datetime on epoch" (datetime year: 1970 month: 01 day: 01 hour: 00 minute: 00 second: 00 tz: "UTC") (unix-time->datetime 0)) -(test-equal "unix-time->datetime before epoch" #1919-04-20T11:33:20Z +(test-equal "unix-time->datetime before epoch" (datetime year: 1919 month: 04 day: 20 hour: 11 minute: 33 second: 20 tz: "UTC") (unix-time->datetime -1600000000)) -;; (unix-time->datetime (expt 2 31)) ; => #2038-01-19T03:14:08Z -;; (unix-time->datetime (1+ (expt 2 31))) ; => #2038-01-19T03:14:09Z -;; (unix-time->datetime (- (expt 2 31))) ; => #1901-12-13T20:45:52Z +;; (unix-time->datetime (expt 2 31)) ; => (datetime year: 2038 month: 01 day: 19 hour: 03 minute: 14 second: 08 tz: "UTC") +;; (unix-time->datetime (1+ (expt 2 31))) ; => (datetime year: 2038 month: 01 day: 19 hour: 03 minute: 14 second: 09 tz: "UTC") +;; (unix-time->datetime (- (expt 2 31))) ; => (datetime year: 1901 month: 12 day: 13 hour: 20 minute: 45 second: 52 tz: "UTC") (test-assert "Current datetime returns a datetime" @@ -412,50 +412,50 @@ as-datetime (test-equal "365 days in regular year" 365 (days-in-year (date year: 2022))) (test-equal "366 days in leap year" 366 (days-in-year (date year: 2000))) -(test-equal "Start of month" #2020-01-01 (start-of-month #2020-01-15)) -(test-equal "End of month" #2000-02-29 (end-of-month #2000-02-01)) +(test-equal "Start of month" (date year: 2020 month: 01 day: 01) (start-of-month (date year: 2020 month: 01 day: 15))) +(test-equal "End of month" (date year: 2000 month: 02 day: 29) (end-of-month (date year: 2000 month: 02 day: 01))) -(test-equal "Start of year" #2020-01-01 (start-of-year #2020-12-31)) +(test-equal "Start of year" (date year: 2020 month: 01 day: 01) (start-of-year (date year: 2020 month: 12 day: 31))) ;; Note that end-of-year (apparently) doesn't exist (test-group "Date streams" (test-equal "Day stream" - (list #2020-01-01 #2020-01-02 #2020-01-03 #2020-01-04 #2020-01-05) - (stream->list 5 (day-stream #2020-01-01))) + (list (date year: 2020 month: 01 day: 01) (date year: 2020 month: 01 day: 02) (date year: 2020 month: 01 day: 03) (date year: 2020 month: 01 day: 04) (date year: 2020 month: 01 day: 05)) + (stream->list 5 (day-stream (date year: 2020 month: 01 day: 01)))) (test-equal "Week stream" - (list #2020-01-01 #2020-02-01 #2020-03-01 #2020-04-01 #2020-05-01) - (stream->list 5 (month-stream #2020-01-01))) + (list (date year: 2020 month: 01 day: 01) (date year: 2020 month: 02 day: 01) (date year: 2020 month: 03 day: 01) (date year: 2020 month: 04 day: 01) (date year: 2020 month: 05 day: 01)) + (stream->list 5 (month-stream (date year: 2020 month: 01 day: 01)))) (test-equal "Month stream" - (list #2020-01-01 #2020-01-08 #2020-01-15 #2020-01-22 #2020-01-29) - (stream->list 5 (week-stream #2020-01-01)))) + (list (date year: 2020 month: 01 day: 01) (date year: 2020 month: 01 day: 08) (date year: 2020 month: 01 day: 15) (date year: 2020 month: 01 day: 22) (date year: 2020 month: 01 day: 29)) + (stream->list 5 (week-stream (date year: 2020 month: 01 day: 01))))) ;; See time< tests for more context (test-group "Min/max" (test-equal "Time min" - #07:40:50 (time-min #10:20:30 #07:40:50)) + (time hour: 07 minute: 40 second: 50) (time-min (time hour: 10 minute: 20 second: 30) (time hour: 07 minute: 40 second: 50))) (test-equal "Time max" - #10:20:30 (time-max #10:20:30 #07:40:50)) + (time hour: 10 minute: 20 second: 30) (time-max (time hour: 10 minute: 20 second: 30) (time hour: 07 minute: 40 second: 50))) (test-equal "Date min" - #2020-02-02 (date-min #2020-02-02 #2020-03-01)) + (date year: 2020 month: 02 day: 02) (date-min (date year: 2020 month: 02 day: 02) (date year: 2020 month: 03 day: 01))) (test-equal "Date max" - #2020-03-01 (date-max #2020-02-02 #2020-03-01)) + (date year: 2020 month: 03 day: 01) (date-max (date year: 2020 month: 02 day: 02) (date year: 2020 month: 03 day: 01))) (test-equal "Datetime min" - #2020-02-02T10:20:30 (datetime-min #2020-02-02T10:20:30 #2020-03-01T07:40:50)) + (datetime year: 2020 month: 02 day: 02 hour: 10 minute: 20 second: 30) (datetime-min (datetime year: 2020 month: 02 day: 02 hour: 10 minute: 20 second: 30) (datetime year: 2020 month: 03 day: 01 hour: 07 minute: 40 second: 50))) (test-equal "Datetime max" - #2020-03-01T07:40:50 (datetime-max #2020-02-02T10:20:30 #2020-03-01T07:40:50))) + (datetime year: 2020 month: 03 day: 01 hour: 07 minute: 40 second: 50) (datetime-max (datetime year: 2020 month: 02 day: 02 hour: 10 minute: 20 second: 30) (datetime year: 2020 month: 03 day: 01 hour: 07 minute: 40 second: 50)))) -(test-equal "Week day" thu (week-day #2022-06-23)) +(test-equal "Week day" thu (week-day (date year: 2022 month: 06 day: 23))) -(test-equal "week-1-start" #2019-12-30 (week-1-start #2020-01-01 mon)) +(test-equal "week-1-start" (date year: 2019 month: 12 day: 30) (week-1-start (date year: 2020 month: 01 day: 01) mon)) ;; Possibly add case where the end of the year uses next years week numbers -(test-equal "Week number at end of year" 53 (week-number #2008-12-31 sun)) -(test-equal "Week number at start of year" 53 (week-number #2009-01-01 sun)) +(test-equal "Week number at end of year" 53 (week-number (date year: 2008 month: 12 day: 31) sun)) +(test-equal "Week number at start of year" 53 (week-number (date year: 2009 month: 01 day: 01) sun)) -(test-equal #2008-12-28 (date-starting-week 53 (date year: 2008) sun)) -(test-equal #2007-12-30 (date-starting-week 1 (date year: 2008) sun)) +(test-equal (date year: 2008 month: 12 day: 28) (date-starting-week 53 (date year: 2008) sun)) +(test-equal (date year: 2007 month: 12 day: 30) (date-starting-week 1 (date year: 2008) sun)) (test-group "Week day name" (test-equal "Simple" "Saturday" (week-day-name sat locale: en_US)) @@ -473,68 +473,68 @@ as-datetime ;; | | : | | : | || | : | || | : | || | : |s2| ;; | | : | | : | | : | | : : | | (test-assert "End of S1 overlaps start of S2" - (timespan-overlaps? #10:00:00 #12:00:00 - #11:00:00 #13:00:00)) + (timespan-overlaps? (time hour: 10 minute: 00 second: 00) (time hour: 12 minute: 00 second: 00) + (time hour: 11 minute: 00 second: 00) (time hour: 13 minute: 00 second: 00))) (test-assert "Start of S1 overlaps end of S2" - (timespan-overlaps? #11:00:00 #13:00:00 - #10:00:00 #12:00:00)) + (timespan-overlaps? (time hour: 11 minute: 00 second: 00) (time hour: 13 minute: 00 second: 00) + (time hour: 10 minute: 00 second: 00) (time hour: 12 minute: 00 second: 00))) (test-assert "S1 complete encompasses S2" - (timespan-overlaps? #10:00:00 #13:00:00 - #11:00:00 #12:00:00)) + (timespan-overlaps? (time hour: 10 minute: 00 second: 00) (time hour: 13 minute: 00 second: 00) + (time hour: 11 minute: 00 second: 00) (time hour: 12 minute: 00 second: 00))) (test-assert "S2 complete encompasses S1" - (timespan-overlaps? #11:00:00 #12:00:00 - #10:00:00 #13:00:00)) + (timespan-overlaps? (time hour: 11 minute: 00 second: 00) (time hour: 12 minute: 00 second: 00) + (time hour: 10 minute: 00 second: 00) (time hour: 13 minute: 00 second: 00))) (test-assert "S1 is equal to S2" - (timespan-overlaps? #11:00:00 #12:00:00 - #11:00:00 #12:00:00)) + (timespan-overlaps? (time hour: 11 minute: 00 second: 00) (time hour: 12 minute: 00 second: 00) + (time hour: 11 minute: 00 second: 00) (time hour: 12 minute: 00 second: 00))) (test-assert "S1 dosesn't overlap S2" (not - (timespan-overlaps? #10:00:00 #11:00:00 - #12:00:00 #13:00:00))) + (timespan-overlaps? (time hour: 10 minute: 00 second: 00) (time hour: 11 minute: 00 second: 00) + (time hour: 12 minute: 00 second: 00) (time hour: 13 minute: 00 second: 00)))) (test-assert "If the events only share an instant they don't overlap" (not - (timespan-overlaps? #10:00:00 #12:00:00 - #12:00:00 #14:00:00)))) + (timespan-overlaps? (time hour: 10 minute: 00 second: 00) (time hour: 12 minute: 00 second: 00) + (time hour: 12 minute: 00 second: 00) (time hour: 14 minute: 00 second: 00))))) -(test-equal #2022-06-25 (find-first-week-day sat #2022-06-23)) +(test-equal (date year: 2022 month: 06 day: 25) (find-first-week-day sat (date year: 2022 month: 06 day: 23))) (test-group "All weekdays in <>" (test-equal "month, if starting from beginning of month" - (list #2022-06-03 #2022-06-10 #2022-06-17 #2022-06-24) - (all-wday-in-month fri #2022-06-01)) + (list (date year: 2022 month: 06 day: 03) (date year: 2022 month: 06 day: 10) (date year: 2022 month: 06 day: 17) (date year: 2022 month: 06 day: 24)) + (all-wday-in-month fri (date year: 2022 month: 06 day: 01))) (test-equal "month, if starting from the middle" - (list #2022-06-24) - (all-wday-in-month fri #2022-06-23)) + (list (date year: 2022 month: 06 day: 24)) + (all-wday-in-month fri (date year: 2022 month: 06 day: 23))) (test-equal "year, if starting from the beggining" - (list #2022-01-07 #2022-01-14 #2022-01-21 #2022-01-28 #2022-02-04 #2022-02-11 #2022-02-18 #2022-02-25 #2022-03-04 #2022-03-11 #2022-03-18 #2022-03-25 #2022-04-01 #2022-04-08 #2022-04-15 #2022-04-22 #2022-04-29 #2022-05-06 #2022-05-13 #2022-05-20 #2022-05-27 #2022-06-03 #2022-06-10 #2022-06-17 #2022-06-24 #2022-07-01 #2022-07-08 #2022-07-15 #2022-07-22 #2022-07-29 #2022-08-05 #2022-08-12 #2022-08-19 #2022-08-26 #2022-09-02 #2022-09-09 #2022-09-16 #2022-09-23 #2022-09-30 #2022-10-07 #2022-10-14 #2022-10-21 #2022-10-28 #2022-11-04 #2022-11-11 #2022-11-18 #2022-11-25 #2022-12-02 #2022-12-09 #2022-12-16 #2022-12-23 #2022-12-30) - (all-wday-in-year fri #2022-01-01)) + (list (date year: 2022 month: 01 day: 07) (date year: 2022 month: 01 day: 14) (date year: 2022 month: 01 day: 21) (date year: 2022 month: 01 day: 28) (date year: 2022 month: 02 day: 04) (date year: 2022 month: 02 day: 11) (date year: 2022 month: 02 day: 18) (date year: 2022 month: 02 day: 25) (date year: 2022 month: 03 day: 04) (date year: 2022 month: 03 day: 11) (date year: 2022 month: 03 day: 18) (date year: 2022 month: 03 day: 25) (date year: 2022 month: 04 day: 01) (date year: 2022 month: 04 day: 08) (date year: 2022 month: 04 day: 15) (date year: 2022 month: 04 day: 22) (date year: 2022 month: 04 day: 29) (date year: 2022 month: 05 day: 06) (date year: 2022 month: 05 day: 13) (date year: 2022 month: 05 day: 20) (date year: 2022 month: 05 day: 27) (date year: 2022 month: 06 day: 03) (date year: 2022 month: 06 day: 10) (date year: 2022 month: 06 day: 17) (date year: 2022 month: 06 day: 24) (date year: 2022 month: 07 day: 01) (date year: 2022 month: 07 day: 08) (date year: 2022 month: 07 day: 15) (date year: 2022 month: 07 day: 22) (date year: 2022 month: 07 day: 29) (date year: 2022 month: 08 day: 05) (date year: 2022 month: 08 day: 12) (date year: 2022 month: 08 day: 19) (date year: 2022 month: 08 day: 26) (date year: 2022 month: 09 day: 02) (date year: 2022 month: 09 day: 09) (date year: 2022 month: 09 day: 16) (date year: 2022 month: 09 day: 23) (date year: 2022 month: 09 day: 30) (date year: 2022 month: 10 day: 07) (date year: 2022 month: 10 day: 14) (date year: 2022 month: 10 day: 21) (date year: 2022 month: 10 day: 28) (date year: 2022 month: 11 day: 04) (date year: 2022 month: 11 day: 11) (date year: 2022 month: 11 day: 18) (date year: 2022 month: 11 day: 25) (date year: 2022 month: 12 day: 02) (date year: 2022 month: 12 day: 09) (date year: 2022 month: 12 day: 16) (date year: 2022 month: 12 day: 23) (date year: 2022 month: 12 day: 30)) + (all-wday-in-year fri (date year: 2022 month: 01 day: 01))) (test-equal "year, if starting from the middle" - (list #2022-06-03 #2022-06-10 #2022-06-17 #2022-06-24 #2022-07-01 #2022-07-08 #2022-07-15 #2022-07-22 #2022-07-29 #2022-08-05 #2022-08-12 #2022-08-19 #2022-08-26 #2022-09-02 #2022-09-09 #2022-09-16 #2022-09-23 #2022-09-30 #2022-10-07 #2022-10-14 #2022-10-21 #2022-10-28 #2022-11-04 #2022-11-11 #2022-11-18 #2022-11-25 #2022-12-02 #2022-12-09 #2022-12-16 #2022-12-23 #2022-12-30) - (all-wday-in-year fri #2022-06-01))) + (list (date year: 2022 month: 06 day: 03) (date year: 2022 month: 06 day: 10) (date year: 2022 month: 06 day: 17) (date year: 2022 month: 06 day: 24) (date year: 2022 month: 07 day: 01) (date year: 2022 month: 07 day: 08) (date year: 2022 month: 07 day: 15) (date year: 2022 month: 07 day: 22) (date year: 2022 month: 07 day: 29) (date year: 2022 month: 08 day: 05) (date year: 2022 month: 08 day: 12) (date year: 2022 month: 08 day: 19) (date year: 2022 month: 08 day: 26) (date year: 2022 month: 09 day: 02) (date year: 2022 month: 09 day: 09) (date year: 2022 month: 09 day: 16) (date year: 2022 month: 09 day: 23) (date year: 2022 month: 09 day: 30) (date year: 2022 month: 10 day: 07) (date year: 2022 month: 10 day: 14) (date year: 2022 month: 10 day: 21) (date year: 2022 month: 10 day: 28) (date year: 2022 month: 11 day: 04) (date year: 2022 month: 11 day: 11) (date year: 2022 month: 11 day: 18) (date year: 2022 month: 11 day: 25) (date year: 2022 month: 12 day: 02) (date year: 2022 month: 12 day: 09) (date year: 2022 month: 12 day: 16) (date year: 2022 month: 12 day: 23) (date year: 2022 month: 12 day: 30)) + (all-wday-in-year fri (date year: 2022 month: 06 day: 01)))) ;; TODO in-date-range? (test-equal "weekday-list" (list wed thu fri sat sun mon tue) (weekday-list wed)) -(test-equal "start of week" #2022-06-20 (start-of-week #2022-06-23 mon)) -(test-equal "end of week" #2022-06-26 (end-of-week #2022-06-23 mon)) +(test-equal "start of week" (date year: 2022 month: 06 day: 20) (start-of-week (date year: 2022 month: 06 day: 23) mon)) +(test-equal "end of week" (date year: 2022 month: 06 day: 26) (end-of-week (date year: 2022 month: 06 day: 23) mon)) (test-group "month-days" - (call-with-values (lambda () (month-days #2022-06-01 mon)) + (call-with-values (lambda () (month-days (date year: 2022 month: 06 day: 01) mon)) (lambda (before actual after) - (test-equal "before" (list #2022-05-30 #2022-05-31) before) - (test-equal "actual" (stream->list 30 (day-stream #2022-06-01)) actual) - (test-equal "after" (list #2022-07-01 #2022-07-02 #2022-07-03) after)))) + (test-equal "before" (list (date year: 2022 month: 05 day: 30) (date year: 2022 month: 05 day: 31)) before) + (test-equal "actual" (stream->list 30 (day-stream (date year: 2022 month: 06 day: 01))) actual) + (test-equal "after" (list (date year: 2022 month: 07 day: 01) (date year: 2022 month: 07 day: 02) (date year: 2022 month: 07 day: 03)) after)))) (test-group "Days in interval" - (test-equal "Steps from start to end of month" 31 (days-in-interval #2022-01-01 #2022-01-31)) - (test-error "Negative intervals should fail" 'misc-error (days-in-interval #2022-01-01 #2020-01-31))) + (test-equal "Steps from start to end of month" 31 (days-in-interval (date year: 2022 month: 01 day: 01) (date year: 2022 month: 01 day: 31))) + (test-error "Negative intervals should fail" 'misc-error (days-in-interval (date year: 2022 month: 01 day: 01) (date year: 2020 month: 01 day: 31)))) -(test-equal "Year day" 191 (year-day #2020-07-09)) +(test-equal "Year day" 191 (year-day (date year: 2020 month: 07 day: 09))) (test-group "Convertions to decimal time" (test-group "Time->decimal-hour" @@ -550,7 +550,7 @@ in-date-range? (test-error "Can't get length of month without information about which month" 'misc-error (datetime->decimal-hour (datetime month: 1))) (test-equal "Can get length of month if we have a month" - (* 31 24.0) (datetime->decimal-hour (datetime month: 1) #2020-01-01)))) + (* 31 24.0) (datetime->decimal-hour (datetime month: 1) (date year: 2020 month: 01 day: 01))))) ;; TODO date-range @@ -569,20 +569,20 @@ date-range (test-equal "02" (datetime->string (datetime month: 2) "~m")) (test-equal "04" (datetime->string (datetime day: 4) "~d")) (test-equal " 4" (datetime->string (datetime day: 4) "~e")) - (test-equal "1600000000" (datetime->string #2020-09-13T12:26:40Z "~s")) + (test-equal "1600000000" (datetime->string (datetime year: 2020 month: 09 day: 13 hour: 12 minute: 26 second: 40 tz: "UTC") "~s")) - (test-equal "2022-10-20" (datetime->string (datetime date: #2022-10-20) "~1")) - (test-equal "10:20:30" (datetime->string (datetime time: #10:20:30) "~3")) + (test-equal "2022-10-20" (datetime->string (datetime date: (date year: 2022 month: 10 day: 20)) "~1")) + (test-equal "10:20:30" (datetime->string (datetime time: (time hour: 10 minute: 20 second: 30)) "~3")) (test-group "Locale dependant (en_US)" - (test-equal "Saturday" (datetime->string (datetime date: (find-first-week-day sat #2020-01-01)) "~A" en_US)) - (test-equal "Sat" (datetime->string (datetime date: (find-first-week-day sat #2020-01-01)) "~a" en_US)) + (test-equal "Saturday" (datetime->string (datetime date: (find-first-week-day sat (date year: 2020 month: 01 day: 01))) "~A" en_US)) + (test-equal "Sat" (datetime->string (datetime date: (find-first-week-day sat (date year: 2020 month: 01 day: 01))) "~a" en_US)) (test-equal "January" (datetime->string (datetime date: (date month: 1)) "~B" en_US)) (test-equal "Jan" (datetime->string (datetime date: (date month: 1)) "~b" en_US))) (test-group "Locale dependant (sv_SE)" - (test-equal "lördag" (datetime->string (datetime date: (find-first-week-day sat #2020-01-01)) "~A" sv_SE)) - (test-equal "lör" (datetime->string (datetime date: (find-first-week-day sat #2020-01-01)) "~a" sv_SE)) + (test-equal "lördag" (datetime->string (datetime date: (find-first-week-day sat (date year: 2020 month: 01 day: 01))) "~A" sv_SE)) + (test-equal "lör" (datetime->string (datetime date: (find-first-week-day sat (date year: 2020 month: 01 day: 01))) "~a" sv_SE)) (test-equal "januari" (datetime->string (datetime date: (date month: 1)) "~B" sv_SE)) (test-equal "jan" (datetime->string (datetime date: (date month: 1)) "~b" sv_SE))) @@ -593,17 +593,17 @@ date-range (test-equal "Default fomat specifier gives ISO-formatted date" - "2006-01-02T15:04:05" (datetime->string #2006-01-02T15:04:05)) + "2006-01-02T15:04:05" (datetime->string (datetime year: 2006 month: 01 day: 02 hour: 15 minute: 04 second: 05))) (test-group "Invalid specifiers" (test-equal "" (datetime->string (datetime) "~x" allow-unknown?: #t)) (test-error 'misc-error (datetime->string (datetime) "~x"))) (test-group "Print syntax for datatypes" - (test-equal "Date writer" "#2020-01-02" (with-output-to-string (lambda () (write #2020-01-02)))) - (test-equal "Time writer" "#20:30:40" (with-output-to-string (lambda () (write #20:30:40)))) - (test-equal "Datetime writer" "#2020-01-02T20:30:40" (with-output-to-string (lambda () (write #2020-01-02T20:30:40)))) - (test-equal "Datetime writer (with tz)" "#2020-01-02T20:30:40Z" (with-output-to-string (lambda () (write #2020-01-02T20:30:40Z)))))) + (test-equal "Date writer" "#2020-01-02" (with-output-to-string (lambda () (write (date year: 2020 month: 01 day: 02))))) + (test-equal "Time writer" "#20:30:40" (with-output-to-string (lambda () (write (time hour: 20 minute: 30 second: 40))))) + (test-equal "Datetime writer" "#2020-01-02T20:30:40" (with-output-to-string (lambda () (write (datetime year: 2020 month: 01 day: 02 hour: 20 minute: 30 second: 40))))) + (test-equal "Datetime writer (with tz)" "#2020-01-02T20:30:40Z" (with-output-to-string (lambda () (write (datetime year: 2020 month: 01 day: 02 hour: 20 minute: 30 second: 40 tz: "UTC"))))))) ;; Really basic tests, since these are rather thin wrappers (test-equal "date->string" "0000-00-00" (date->string (date))) @@ -616,25 +616,25 @@ date-range (test-assert "Zero dates are all equal" (date=)) (test-assert "A single date is equal to itself" - (date=? #2020-10-20)) + (date=? (date year: 2020 month: 10 day: 20))) (test-assert "Two dates are equal to each other" - (date= #2020-10-20 #2020-10-20)) + (date= (date year: 2020 month: 10 day: 20) (date year: 2020 month: 10 day: 20))) (test-assert "Two dates which are NOT equal to each other" - (not (date= #2020-10-20 #2020-10-21))) + (not (date= (date year: 2020 month: 10 day: 20) (date year: 2020 month: 10 day: 21)))) (test-assert "More than two dates which are all equal" - (date=? #2020-10-20 #2020-10-20 #2020-10-20))) + (date=? (date year: 2020 month: 10 day: 20) (date year: 2020 month: 10 day: 20) (date year: 2020 month: 10 day: 20)))) (test-group "time" (test-assert "Zero times are all equal" (time=)) (test-assert "A single time is equal to itself" - (time=? #20:30:40)) + (time=? (time hour: 20 minute: 30 second: 40))) (test-assert "Two times are equal to each other" - (time= #20:30:40 #20:30:40)) + (time= (time hour: 20 minute: 30 second: 40) (time hour: 20 minute: 30 second: 40))) (test-assert "Two times which are NOT equal to each other" - (not (time= #20:30:40 #10:30:40))) + (not (time= (time hour: 20 minute: 30 second: 40) (time hour: 10 minute: 30 second: 40)))) (test-assert "More than two times which are all equal" - (time=? #20:30:40 #20:30:40 #20:30:40))) + (time=? (time hour: 20 minute: 30 second: 40) (time hour: 20 minute: 30 second: 40) (time hour: 20 minute: 30 second: 40)))) (test-group "Datetime" (test-assert "Zero datetimes \"all\" are equal" @@ -722,30 +722,30 @@ date/-time> date/-time>? date/-time>= date/-time>=? (test-group "Simple cases" (test-group "Days" - (test-equal "Add" #2020-01-06 (date+ #2020-01-01 (date day: 5))) - (test-equal "Remove" #2020-01-01 (date- #2020-01-06 (date day: 5)))) + (test-equal "Add" (date year: 2020 month: 01 day: 06) (date+ (date year: 2020 month: 01 day: 01) (date day: 5))) + (test-equal "Remove" (date year: 2020 month: 01 day: 01) (date- (date year: 2020 month: 01 day: 06) (date day: 5)))) (test-group "Months" - (test-equal "Add" #2020-06-01 (date+ #2020-01-01 (date month: 5))) - (test-equal "Remove" #2020-01-01 (date- #2020-06-01 (date month: 5)))) + (test-equal "Add" (date year: 2020 month: 06 day: 01) (date+ (date year: 2020 month: 01 day: 01) (date month: 5))) + (test-equal "Remove" (date year: 2020 month: 01 day: 01) (date- (date year: 2020 month: 06 day: 01) (date month: 5)))) (test-group "Years" - (test-equal "Add" #2022-01-01 (date+ #2020-01-01 (date year: 2))) - (test-equal "Remove" #2020-01-01 (date- #2022-01-01 (date year: 2))))) + (test-equal "Add" (date year: 2022 month: 01 day: 01) (date+ (date year: 2020 month: 01 day: 01) (date year: 2))) + (test-equal "Remove" (date year: 2020 month: 01 day: 01) (date- (date year: 2022 month: 01 day: 01) (date year: 2))))) (test-group "Many operands" - (test-equal #2021-02-02 - (date+ #2020-01-01 + (test-equal (date year: 2021 month: 02 day: 02) + (date+ (date year: 2020 month: 01 day: 01) (date day: 1) (date month: 1) (date year: 1)))) (test-group "Overflow" ;; Years don't overflow, so no need to test - (test-equal "Day overflow" #2022-02-01 (date+ #2022-01-31 (date day: 1))) - (test-equal "Month overflow" #2023-01-01 (date+ #2022-12-01 (date month: 1))) - (test-equal "Date+Month overflow" #2023-01-01 (date+ #2022-12-31 (date day: 1)))) + (test-equal "Day overflow" (date year: 2022 month: 02 day: 01) (date+ (date year: 2022 month: 01 day: 31) (date day: 1))) + (test-equal "Month overflow" (date year: 2023 month: 01 day: 01) (date+ (date year: 2022 month: 12 day: 01) (date month: 1))) + (test-equal "Date+Month overflow" (date year: 2023 month: 01 day: 01) (date+ (date year: 2022 month: 12 day: 31) (date day: 1)))) ;; NOTE - (test-equal #2020-02-31 (date+ #2020-01-31 (date month: 1))) + (test-equal (date year: 2020 month: 02 day: 31) (date+ (date year: 2020 month: 01 day: 31) (date month: 1))) ) (test-group "Time" @@ -755,31 +755,31 @@ date/-time> date/-time>? date/-time>= date/-time>=? (test-group "Simple cases" (test-group "Seconds" - (test-equal "Add" #20:00:40 (time+ #20:00:00 (time second: 40))) - (test-equal "Remove" #20:00:00 (time- #20:00:40 (time second: 40)))) + (test-equal "Add" (time hour: 20 minute: 00 second: 40) (time+ (time hour: 20 minute: 00 second: 00) (time second: 40))) + (test-equal "Remove" (time hour: 20 minute: 00 second: 00) (time- (time hour: 20 minute: 00 second: 40) (time second: 40)))) (test-group "Minutes" - (test-equal "Add" #20:10:00 (time+ #20:00:00 (time minute: 10))) - (test-equal "Remove" #20:00:00 (time- #20:10:00 (time minute: 10)))) + (test-equal "Add" (time hour: 20 minute: 10 second: 00) (time+ (time hour: 20 minute: 00 second: 00) (time minute: 10))) + (test-equal "Remove" (time hour: 20 minute: 00 second: 00) (time- (time hour: 20 minute: 10 second: 00) (time minute: 10)))) (test-group "Hours" - (test-equal "Add" #22:00:00 (time+ #20:00:00 (time hour: 2))) - (test-equal "Remove" #20:00:00 (time- #22:00:00 (time hour: 2))))) + (test-equal "Add" (time hour: 22 minute: 00 second: 00) (time+ (time hour: 20 minute: 00 second: 00) (time hour: 2))) + (test-equal "Remove" (time hour: 20 minute: 00 second: 00) (time- (time hour: 22 minute: 00 second: 00) (time hour: 2))))) (test-group "Overflowing cases" (test-group "Addition" (test-group "Single overflow" - (call-with-values (lambda () (time+ #20:00:00 (time hour: 5))) + (call-with-values (lambda () (time+ (time hour: 20 minute: 00 second: 00) (time hour: 5))) (lambda (result overflow) (test-equal "Time" (time hour: 1) result) (test-equal "Overflow" 1 overflow)))) (test-group "Mulitple overflows" - (call-with-values (lambda () (time+ #20:00:00 (time hour: 5) (time hour: 24))) + (call-with-values (lambda () (time+ (time hour: 20 minute: 00 second: 00) (time hour: 5) (time hour: 24))) (lambda (result overflow) (test-equal "Time" (time hour: 1) result) (test-equal "Overflow" 2 overflow))))) (test-group "Subtraction" (test-group "Single overflow" - (call-with-values (lambda () (time- #20:00:00 (time hour: 25))) + (call-with-values (lambda () (time- (time hour: 20 minute: 00 second: 00) (time hour: 25))) (lambda (result overflow) (test-equal "Time" (time hour: 19) result) (test-equal "Overflow" 1 overflow)))) @@ -794,10 +794,10 @@ datetime+ datetime- (test-group "Date difference" (test-assert "The differente between a date and itself is zero" - (date-zero? (date-difference #2022-02-02 #2022-02-02))) + (date-zero? (date-difference (date year: 2022 month: 02 day: 02) (date year: 2022 month: 02 day: 02)))) (test-error "Later date must be first" 'misc-error - (date-difference #2020-01-01 #2021-01-01)) + (date-difference (date year: 2020 month: 01 day: 01) (date year: 2021 month: 01 day: 01))) (test-error "Negative months are invalid" 'misc-error (date-difference (date) (date month: -1))) @@ -808,3 +808,5 @@ datetime+ datetime- ;; TODO datetime-difference + +'((datetime)) diff --git a/tests/unit/datetime/timespec.scm b/tests/unit/datetime/timespec.scm new file mode 100644 index 00000000..76fdd572 --- /dev/null +++ b/tests/unit/datetime/timespec.scm @@ -0,0 +1,98 @@ +(define-module (test timespec) + :use-module (srfi srfi-64) + :use-module (srfi srfi-88) + :use-module (datetime) + :use-module (datetime timespec)) + +(test-equal "The empty string parses to the empty timespec" + (timespec-zero) (parse-time-spec "")) + +(test-group "timespec-add" + + (test-equal "Zero operands gives 0" + (timespec-zero) (timespec-add)) + + (let ((ts (make-timespec (time hour: 10 minute: 20 second: 30) '- #\z))) + (test-equal "Single operand gives that operand" + ts (timespec-add ts))) + + (test-equal "0 + 0 = 0" + (timespec-zero) (timespec-add (timespec-zero) (timespec-zero))) + + (test-group + "+ -" + (test-equal "Remove a number less than the base" + (make-timespec (time hour: 10 minute: 00 second: 00) '+ #\w) + (timespec-add (make-timespec (time hour: 10 minute: 20 second: 30) + '+ #\w) + (make-timespec (time minute: 20 second: 30) + '- #\w))) + + (test-equal "Remove a number greater than the base" + (make-timespec (time hour: 01 minute: 00 second: 00) '- #\w) + (timespec-add (make-timespec (time hour: 10 minute: 00 second: 00) '+ #\w) + (make-timespec (time hour: 11 minute: 00 second: 00) '- #\w))) + + (test-equal "x + -x = 0" + (timespec-zero) (timespec-add (make-timespec (time hour: 10 minute: 20 second: 30) '+ #\w) + (make-timespec (time hour: 10 minute: 20 second: 30) '- #\w)))) + + (test-group "- +" + (test-equal "Add a number less than the (negative) base" + (make-timespec (time hour: 10 minute: 00 second: 00) '+ #\w) + (timespec-add (make-timespec (time hour: 10 minute: 20 second: 30) '- #\w) + (make-timespec (time hour: 00 minute: 20 second: 30) '+ #\w))) + + (test-equal "Add a number greater than the (negative) base" + (make-timespec (time hour: 01 minute: 00 second: 00) '- #\w) + (timespec-add (make-timespec (time hour: 10 minute: 00 second: 00) '- #\w) + (make-timespec (time hour: 11 minute: 00 second: 00) '+ #\w))) + + (test-equal "-x + x = 0" + (timespec-zero) (timespec-add (make-timespec (time hour: 10 minute: 20 second: 30) '- #\w) + (make-timespec (time hour: 10 minute: 20 second: 30) '+ #\w)))) + + (test-group "+ +" + (test-equal "x + x = 2x" + (make-timespec (time hour: 20 minute: 41 second: 00) '+ #\w) + (timespec-add (make-timespec (time hour: 10 minute: 20 second: 30) '+ #\w) + (make-timespec (time hour: 10 minute: 20 second: 30) '+ #\w)))) + + (test-group "- -" + (test-equal "-x + -x = -2x" + (make-timespec (time hour: 20 minute: 41 second: 00) '- #\w) + (timespec-add (make-timespec (time hour: 10 minute: 20 second: 30) '- #\w) + (make-timespec (time hour: 10 minute: 20 second: 30) '- #\w)))) + + ;; add more than two timespecs + + ;; add timespecs of differing types + ) + +(test-group "parse-time-spec" + ;; TODO what even is this case? + (test-equal (make-timespec (time) '+ #\g) (parse-time-spec "-g")) + + (test-equal "Parse direct date, with hour minute and second" + (make-timespec (time hour: 20 minute: 00 second: 00) '+ #\w) + (parse-time-spec "20:00:00")) + (test-equal "Parse direct date, with hour and minute" + (make-timespec (time hour: 20 minute: 00 second: 00) '+ #\w) + (parse-time-spec "20:00")) + (test-equal "Parse direct date, with just hour" + (make-timespec (time hour: 20 minute: 00 second: 00) '+ #\w) + (parse-time-spec "20")) + + (test-equal "Parse timespec with letter at end" + (make-timespec (time hour: 20 minute: 00 second: 00) '+ #\g) + (parse-time-spec "20:00g")) + + (test-equal "Parse negative timespec" + (make-timespec (time hour: 20 minute: 00 second: 00) '- #\w) + (parse-time-spec "-20")) + + (test-equal "Parse negative timespec with letter at end" + (make-timespec (time hour: 20 minute: 00 second: 00) '- #\z) + (parse-time-spec "-20z"))) + +'((datetime timespec)) diff --git a/tests/test/tz.scm b/tests/unit/datetime/tz.scm index 00a611b3..d335ced3 100644 --- a/tests/test/tz.scm +++ b/tests/unit/datetime/tz.scm @@ -24,12 +24,12 @@ ((TZ "Europe/London")) (test-equal "London winter" - #2020-01-12T13:30:00 + (datetime year: 2020 month: 01 day: 12 hour: 13 minute: 30 second: 00) (get-datetime (parse-ics-datetime "20200112T133000Z"))) (test-equal "London summer" - #2020-06-12T14:30:00 + (datetime year: 2020 month: 06 day: 12 hour: 14 minute: 30 second: 00) (get-datetime (parse-ics-datetime "20200612T133000Z")))) @@ -38,12 +38,12 @@ ((TZ "Europe/Stockholm")) (test-equal "Stockholm winter" - #2020-01-12T14:30:00 + (datetime year: 2020 month: 01 day: 12 hour: 14 minute: 30 second: 00) (get-datetime (parse-ics-datetime "20200112T133000Z"))) (test-equal "Stockholm summer" - #2020-06-12T15:30:00 + (datetime year: 2020 month: 06 day: 12 hour: 15 minute: 30 second: 00) (get-datetime (parse-ics-datetime "20200612T133000Z")))) @@ -77,11 +77,12 @@ (test-equal (datetime date: - #1970-01-01 + (date year: 1970 month: 01 day: 01) time: - #00:00:00 + (time hour: 00 minute: 00 second: 00) tz: "UTC") (unix-time->datetime 0)) +'((datetime)) diff --git a/tests/test/zic.scm b/tests/unit/datetime/zic.scm index 99247cf1..19af169c 100644 --- a/tests/test/zic.scm +++ b/tests/unit/datetime/zic.scm @@ -37,8 +37,8 @@ Link Europe/Zurich Europe/Vaduz (test-equal "Basic Rule" (list ((@@ (datetime zic) make-rule) 'US 1967 1973 4 '(last 0) - ((@ (datetime zic) make-timespec) #02:00:00 '+ #\w) - ((@ (datetime zic) make-timespec) #01:00:00 '+ #\d) + ((@ (datetime zic) make-timespec) (time hour: 02 minute: 00 second: 00) '+ #\w) + ((@ (datetime zic) make-timespec) (time hour: 01 minute: 00 second: 00) '+ #\d) "D")) (call-with-input-string "Rule US 1967 1973 - Apr lastSun 2:00w 1:00d D" parse-zic-file)) @@ -47,7 +47,7 @@ Link Europe/Zurich Europe/Vaduz (test-equal "Basic Zone" (list ((@@ (datetime zic) make-zone) "Asia/Amman" (list ((@@ (datetime zic) make-zone-entry) - (make-timespec #02:00:00 '+ #\w) + (make-timespec (time hour: 02 minute: 00 second: 00) '+ #\w) 'Jordan "EE%sT" #f)))) (call-with-input-string @@ -58,10 +58,10 @@ Link Europe/Zurich Europe/Vaduz (test-equal "Basic Zone with continuation" (list ((@@ (datetime zic) make-zone) "America/Menominee" (list ((@@ (datetime zic) make-zone-entry) - (make-timespec #05:00:00 '- #\w) - #f "EST" #1973-04-29T02:00:00) + (make-timespec (time hour: 05 minute: 00 second: 00) '- #\w) + #f "EST" (datetime year: 1973 month: 04 day: 29 hour: 02 minute: 00 second: 00)) ((@@ (datetime zic) make-zone-entry) - (make-timespec #06:00:00 '- #\w) + (make-timespec (time hour: 06 minute: 00 second: 00) '- #\w) 'US "C%sT" #f)))) ;; Why can't I single read a zone with an until field? (call-with-input-string @@ -73,20 +73,20 @@ Link Europe/Zurich Europe/Vaduz (test-equal "Rules and Zone" (list ((@@ (datetime zic) make-zone) "America/Menominee" (list ((@@ (datetime zic) make-zone-entry) - (make-timespec #05:00:00 '- #\w) - #f "EST" #1973-04-29T02:00:00) + (make-timespec (time hour: 05 minute: 00 second: 00) '- #\w) + #f "EST" (datetime year: 1973 month: 04 day: 29 hour: 02 minute: 00 second: 00)) ((@@ (datetime zic) make-zone-entry) - (make-timespec #06:00:00 '- #\w) + (make-timespec (time hour: 06 minute: 00 second: 00) '- #\w) 'US "C%sT" #f))) ((@@ (datetime zic) make-rule) 'US 1967 1973 dec '(last 0) - (make-timespec #02:00:00 '+ #\w) - (make-timespec #01:00:00 '+ #\w) + (make-timespec (time hour: 02 minute: 00 second: 00) '+ #\w) + (make-timespec (time hour: 01 minute: 00 second: 00) '+ #\w) "D") ((@@ (datetime zic) make-rule) 'US 1967 2006 nov '(last 0) - (make-timespec #02:00:00 '+ #\w) - (make-timespec #00:00:00 '+ #\w) + (make-timespec (time hour: 02 minute: 00 second: 00) '+ #\w) + (make-timespec (time hour: 00 minute: 00 second: 00) '+ #\w) "S")) (call-with-input-string "# Rule NAME FROM TO - IN ON AT SAVE LETTER/S @@ -119,79 +119,79 @@ Zone America/Menominee -5:00 - EST 1973 Apr 29 2:00 (list ((@@ (datetime zic) make-link) "Europe/Vaduz" "Europe/Zurich") ((@@ (datetime zic) make-zone) "Europe/Zurich" (list ((@@ (datetime zic) make-zone-entry) - (make-timespec #00:34:08 '+ #\w) - #f "LMT" #1853-07-16T00:00:00) + (make-timespec (time hour: 00 minute: 34 second: 08) '+ #\w) + #f "LMT" (datetime year: 1853 month: 07 day: 16 hour: 00 minute: 00 second: 00)) ((@@ (datetime zic) make-zone-entry) - (make-timespec #00:29:45 '+ #\w) ; NOTE that the .50 is discarded - #f "BMT" #1894-06-01T00:00:00) + (make-timespec (time hour: 00 minute: 29 second: 45) '+ #\w) ; NOTE that the .50 is discarded + #f "BMT" (datetime year: 1894 month: 06 day: 01 hour: 00 minute: 00 second: 00)) ((@@ (datetime zic) make-zone-entry) - (make-timespec #01:00:00 '+ #\w) - 'Swiss "CE%sT" #1981-01-01T00:00:00) + (make-timespec (time hour: 01 minute: 00 second: 00) '+ #\w) + 'Swiss "CE%sT" (datetime year: 1981 month: 01 day: 01 hour: 00 minute: 00 second: 00)) ((@@ (datetime zic) make-zone-entry) - (make-timespec #01:00:00 '+ #\w) + (make-timespec (time hour: 01 minute: 00 second: 00) '+ #\w) 'EU "CE%sT" #f))) ((@@ (datetime zic) make-rule) 'EU 1996 'maximum 10 '(last 0) - (make-timespec #01:00:00 '+ #\u) - (make-timespec #00:00:00 '+ #\w) + (make-timespec (time hour: 01 minute: 00 second: 00) '+ #\u) + (make-timespec (time hour: 00 minute: 00 second: 00) '+ #\w) "") ((@@ (datetime zic) make-rule) 'EU 1981 'maximum 3 '(last 0) - (make-timespec #01:00:00 '+ #\u) - (make-timespec #01:00:00 '+ #\w) + (make-timespec (time hour: 01 minute: 00 second: 00) '+ #\u) + (make-timespec (time hour: 01 minute: 00 second: 00) '+ #\w) "S") ((@@ (datetime zic) make-rule) 'EU 1979 1995 9 `(last ,sun) - (make-timespec #01:00:00 '+ #\u) - (make-timespec #00:00:00 '+ #\w) + (make-timespec (time hour: 01 minute: 00 second: 00) '+ #\u) + (make-timespec (time hour: 00 minute: 00 second: 00) '+ #\w) "") ((@@ (datetime zic) make-rule) 'EU 1978 'only 10 1 - (make-timespec #01:00:00 '+ #\u) - (make-timespec #00:00:00 '+ #\w) + (make-timespec (time hour: 01 minute: 00 second: 00) '+ #\u) + (make-timespec (time hour: 00 minute: 00 second: 00) '+ #\w) "") ((@@ (datetime zic) make-rule) 'EU 1977 'only 9 `(last ,sun) - (make-timespec #01:00:00 '+ #\u) - (make-timespec #00:00:00 '+ #\w) + (make-timespec (time hour: 01 minute: 00 second: 00) '+ #\u) + (make-timespec (time hour: 00 minute: 00 second: 00) '+ #\w) "") ((@@ (datetime zic) make-rule) 'EU 1977 1980 4 `(> ,sun 1) - (make-timespec #01:00:00 '+ #\u) - (make-timespec #01:00:00 '+ #\w) + (make-timespec (time hour: 01 minute: 00 second: 00) '+ #\u) + (make-timespec (time hour: 01 minute: 00 second: 00) '+ #\w) "S") ((@@ (datetime zic) make-rule) 'Swiss 1941 1942 10 `(> ,mon 1) - (make-timespec #02:00:00 '+ #\w) - (make-timespec #00:00:00 '+ #\w) + (make-timespec (time hour: 02 minute: 00 second: 00) '+ #\w) + (make-timespec (time hour: 00 minute: 00 second: 00) '+ #\w) "") ((@@ (datetime zic) make-rule) 'Swiss 1941 1942 5 `(> ,mon 1) - (make-timespec #01:00:00 '+ #\w) - (make-timespec #01:00:00 '+ #\w) + (make-timespec (time hour: 01 minute: 00 second: 00) '+ #\w) + (make-timespec (time hour: 01 minute: 00 second: 00) '+ #\w) "S")) (call-with-input-string big-sample parse-zic-file))) (test-group "rule->dtstart" (test-equal "last sunday" - #1967-04-30T02:00:00 + (datetime year: 1967 month: 04 day: 30 hour: 02 minute: 00 second: 00) (rule->dtstart ((@@ (datetime zic) make-rule) 'US 1967 1973 4 '(last 0) - ((@ (datetime zic) make-timespec) #02:00:00 '+ #\w) - ((@ (datetime zic) make-timespec) #01:00:00 '+ #\d) + ((@ (datetime zic) make-timespec) (time hour: 02 minute: 00 second: 00) '+ #\w) + ((@ (datetime zic) make-timespec) (time hour: 01 minute: 00 second: 00) '+ #\d) "D"))) (test-equal "sunday >= 1" - #1977-04-03T01:00:00Z + (datetime year: 1977 month: 04 day: 03 hour: 01 minute: 00 second: 00 tz: "UTC") (rule->dtstart ((@@ (datetime zic) make-rule) 'EU 1977 1980 4 `(> ,sun 1) - (make-timespec #01:00:00 '+ #\u) - (make-timespec #01:00:00 '+ #\w) + (make-timespec (time hour: 01 minute: 00 second: 00) '+ #\u) + (make-timespec (time hour: 01 minute: 00 second: 00) '+ #\w) "S"))) ;; Max and min uses dummy dates, which is slightly wrong ;; but shouldn't cause any real problems (test-equal "Minimum time" - #0000-10-30T01:00:00Z + (datetime year: 0000 month: 10 day: 30 hour: 01 minute: 00 second: 00 tz: "UTC") (rule->dtstart ((@@ (datetime zic) make-rule) 'EU 'minimum 2000 10 '(last 0) - (make-timespec #01:00:00 '+ #\u) - (make-timespec #00:00:00 '+ #\w) + (make-timespec (time hour: 01 minute: 00 second: 00) '+ #\u) + (make-timespec (time hour: 00 minute: 00 second: 00) '+ #\w) ""))) (test-equal "Maximum time" @@ -199,8 +199,8 @@ Zone America/Menominee -5:00 - EST 1973 Apr 29 2:00 hour: 1 tz: "UTC") (rule->dtstart ((@@ (datetime zic) make-rule) 'EU 'maximum 2000 10 '(last 0) - (make-timespec #01:00:00 '+ #\u) - (make-timespec #00:00:00 '+ #\w) + (make-timespec (time hour: 01 minute: 00 second: 00) '+ #\u) + (make-timespec (time hour: 00 minute: 00 second: 00) '+ #\w) "")))) (test-group "zone-format" @@ -228,12 +228,12 @@ Zone America/Menominee -5:00 - EST 1973 Apr 29 2:00 (test-equal "Get rules returns correctly, and in order" ;; Rules are sorted (list ((@@ (datetime zic) make-rule) 'Swiss 1941 1942 5 `(> ,mon 1) - (make-timespec #01:00:00 '+ #\w) - (make-timespec #01:00:00 '+ #\w) + (make-timespec (time hour: 01 minute: 00 second: 00) '+ #\w) + (make-timespec (time hour: 01 minute: 00 second: 00) '+ #\w) "S") ((@@ (datetime zic) make-rule) 'Swiss 1941 1942 10 `(> ,mon 1) - (make-timespec #02:00:00 '+ #\w) - (make-timespec #00:00:00 '+ #\w) + (make-timespec (time hour: 02 minute: 00 second: 00) '+ #\w) + (make-timespec (time hour: 00 minute: 00 second: 00) '+ #\w) "")) (get-rule zoneinfo 'Swiss)))) @@ -246,8 +246,8 @@ Zone America/Menominee -5:00 - EST 1973 Apr 29 2:00 bymonth: (list oct)) (rule->rrule ((@@ (datetime zic) make-rule) 'EU 1996 'maximum 10 '(last 0) - (make-timespec #01:00:00 '+ #\u) - (make-timespec #00:00:00 '+ #\w) + (make-timespec (time hour: 01 minute: 00 second: 00) '+ #\u) + (make-timespec (time hour: 00 minute: 00 second: 00) '+ #\w) "") )) @@ -255,8 +255,8 @@ Zone America/Menominee -5:00 - EST 1973 Apr 29 2:00 #f (rule->rrule ((@@ (datetime zic) make-rule) 'EU 1996 'only 10 '(last 2) - (make-timespec #01:00:00 '+ #\u) - (make-timespec #00:00:00 '+ #\w) + (make-timespec (time hour: 01 minute: 00 second: 00) '+ #\u) + (make-timespec (time hour: 00 minute: 00 second: 00) '+ #\w) ""))) (test-equal "with definitive to year" @@ -264,11 +264,11 @@ Zone America/Menominee -5:00 - EST 1973 Apr 29 2:00 freq: 'YEARLY interval: 1 wkst: mon byday: (list (cons -1 tue)) bymonth: (list oct) - until: #2000-01-01T00:00:00) + until: (datetime year: 2000 month: 01 day: 01 hour: 00 minute: 00 second: 00)) (rule->rrule ((@@ (datetime zic) make-rule) 'EU 1996 2000 10 '(last 2) - (make-timespec #01:00:00 '+ #\u) - (make-timespec #00:00:00 '+ #\w) + (make-timespec (time hour: 01 minute: 00 second: 00) '+ #\u) + (make-timespec (time hour: 00 minute: 00 second: 00) '+ #\w) ""))) (test-equal "on being a month day" @@ -278,8 +278,8 @@ Zone America/Menominee -5:00 - EST 1973 Apr 29 2:00 bymonth: (list oct)) (rule->rrule ((@@ (datetime zic) make-rule) 'EU 1996 'maximum 10 2 - (make-timespec #01:00:00 '+ #\u) - (make-timespec #00:00:00 '+ #\w) + (make-timespec (time hour: 01 minute: 00 second: 00) '+ #\u) + (make-timespec (time hour: 00 minute: 00 second: 00) '+ #\w) ""))) (test-equal "on being first day after date" @@ -289,8 +289,8 @@ Zone America/Menominee -5:00 - EST 1973 Apr 29 2:00 bymonth: (list oct)) (rule->rrule ((@@ (datetime zic) make-rule) 'EU 1996 'maximum 10 `(> ,mon 2) - (make-timespec #01:00:00 '+ #\u) - (make-timespec #00:00:00 '+ #\w) + (make-timespec (time hour: 01 minute: 00 second: 00) '+ #\u) + (make-timespec (time hour: 00 minute: 00 second: 00) '+ #\w) ""))) (test-equal "Crash on counting backwards from date" @@ -299,8 +299,8 @@ Zone America/Menominee -5:00 - EST 1973 Apr 29 2:00 (lambda () (rule->rrule ((@@ (datetime zic) make-rule) 'EU 1996 'maximum 10 `(< ,mon 2) - (make-timespec #01:00:00 '+ #\u) - (make-timespec #00:00:00 '+ #\w) + (make-timespec (time hour: 01 minute: 00 second: 00) '+ #\u) + (make-timespec (time hour: 00 minute: 00 second: 00) '+ #\w) ""))) list)) @@ -310,8 +310,10 @@ Zone America/Menominee -5:00 - EST 1973 Apr 29 2:00 (lambda () (rule->rrule ((@@ (datetime zic) make-rule) 'EU 1996 'minimum 10 `(< ,mon 2) - (make-timespec #01:00:00 '+ #\u) - (make-timespec #00:00:00 '+ #\w) + (make-timespec (time hour: 01 minute: 00 second: 00) '+ #\u) + (make-timespec (time hour: 00 minute: 00 second: 00) '+ #\w) ""))) list)) ) + +'((datetime zic)) |