diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-03-07 15:31:00 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-03-07 20:29:14 +0100 |
commit | f7716ac1a87649cad96242f2d5bf0a987d7f430c (patch) | |
tree | b4b84951ef468fd644c42e9e0fee535d879f0387 /tests/test/tz.scm | |
parent | Cleanup in (hnh util path). (diff) | |
download | calp-f7716ac1a87649cad96242f2d5bf0a987d7f430c.tar.gz calp-f7716ac1a87649cad96242f2d5bf0a987d7f430c.tar.xz |
Add new tests.
Diffstat (limited to 'tests/test/tz.scm')
-rw-r--r-- | tests/test/tz.scm | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/tests/test/tz.scm b/tests/test/tz.scm new file mode 100644 index 00000000..245258d0 --- /dev/null +++ b/tests/test/tz.scm @@ -0,0 +1,87 @@ +;;; Commentary: +;; Tests that datetime->unix-time correctly converts between Olssen +;; timezone definitions (e.g. Europe/Stockholm), into correct times +;; and offsets (in unix time). +;; Also indirectly tests the Zone Info Compiler (datetime zic), since +;; the zoneinfo comes from there. +;;; Code: + +(define-module (test tz) + :use-module (srfi srfi-64) + :use-module (srfi srfi-88) + :use-module ((datetime) + :select (parse-ics-datetime + datetime + date + time + datetime->unix-time + unix-time->datetime + get-datetime)) + :use-module ((hnh util) :select (let-env))) + +;; London alternates between +0000 and +0100 +(let-env + ((TZ "Europe/London")) + (test-equal + "London winter" + #2020-01-12T13:30:00 + (get-datetime + (parse-ics-datetime "20200112T133000Z"))) + (test-equal + "London summer" + #2020-06-12T14:30:00 + (get-datetime + (parse-ics-datetime "20200612T133000Z")))) + +;; Stockholm alternates between +0100 and +0200 +(let-env + ((TZ "Europe/Stockholm")) + (test-equal + "Stockholm winter" + #2020-01-12T14:30:00 + (get-datetime + (parse-ics-datetime "20200112T133000Z"))) + (test-equal + "Stockholm summer" + #2020-06-12T15:30:00 + (get-datetime + (parse-ics-datetime "20200612T133000Z")))) + +(test-equal + -10800 + (datetime->unix-time + (parse-ics-datetime + "19700101T000000" + "Europe/Tallinn"))) + +(test-equal + -3600 + (datetime->unix-time + (parse-ics-datetime + "19700101T000000" + "Europe/Stockholm"))) + +(test-equal + 0 + (datetime->unix-time + (parse-ics-datetime "19700101T000000Z"))) + +;; yes, really +(test-equal + -3600 + (datetime->unix-time + (parse-ics-datetime + "19700101T000000" + "Europe/London"))) + +(test-equal + (datetime + date: + #1970-01-01 + time: + #00:00:00 + tz: + "UTC") + (unix-time->datetime 0)) + + |