summaryrefslogtreecommitdiff
path: root/tests/test-calendar-sync--convert-utc-to-local.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-04-05 06:51:20 -0500
committerCraig Jennings <c@cjennings.net>2026-04-05 06:51:20 -0500
commit7eb6c0692d48b8c3d01efba8abcd2bfdfaa7cd31 (patch)
tree2af7aa512feaae39b384939160af68fa0537fc22 /tests/test-calendar-sync--convert-utc-to-local.el
parent47453fd03be79205c6209d31a26cb4f7724af317 (diff)
test(calendar-sync): add 68 tests across 13 files for untested pure functions
Covers core parsing (parse-ics-datetime, parse-timestamp, format-timestamp, split-events, parse-event), date utilities (add-months, add-days, weekday-to-number, date-weekday, event-start-time), and timezone (format-timezone-offset, convert-utc-to-local, localize-parsed-datetime).
Diffstat (limited to 'tests/test-calendar-sync--convert-utc-to-local.el')
-rw-r--r--tests/test-calendar-sync--convert-utc-to-local.el41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/test-calendar-sync--convert-utc-to-local.el b/tests/test-calendar-sync--convert-utc-to-local.el
new file mode 100644
index 00000000..1a5be4d3
--- /dev/null
+++ b/tests/test-calendar-sync--convert-utc-to-local.el
@@ -0,0 +1,41 @@
+;;; test-calendar-sync--convert-utc-to-local.el --- Tests for UTC to local conversion -*- lexical-binding: t; -*-
+
+;;; Commentary:
+;; Tests for calendar-sync--convert-utc-to-local.
+;; Converts UTC datetime to local timezone. Results depend on system timezone.
+
+;;; Code:
+
+(require 'ert)
+(require 'testutil-calendar-sync)
+(require 'calendar-sync)
+
+;;; Normal Cases
+
+(ert-deftest test-calendar-sync--convert-utc-to-local-normal-returns-5-elements ()
+ "Conversion returns (year month day hour minute) list."
+ (let ((result (calendar-sync--convert-utc-to-local 2026 3 15 18 0 0)))
+ (should (= 5 (length result)))
+ (should (numberp (nth 0 result)))
+ (should (numberp (nth 3 result)))))
+
+(ert-deftest test-calendar-sync--convert-utc-to-local-normal-offset-applied ()
+ "Hour differs from UTC input (unless system is UTC)."
+ (let* ((tz-offset (car (current-time-zone)))
+ (result (calendar-sync--convert-utc-to-local 2026 3 15 12 0 0)))
+ (if (= tz-offset 0)
+ (should (= 12 (nth 3 result)))
+ (should-not (= 12 (nth 3 result))))))
+
+;;; Boundary Cases
+
+(ert-deftest test-calendar-sync--convert-utc-to-local-boundary-date-change ()
+ "Late UTC time may shift to next day for western timezones."
+ (let* ((tz-offset (car (current-time-zone)))
+ (result (calendar-sync--convert-utc-to-local 2026 3 15 23 30 0)))
+ ;; For negative offsets, 23:30 UTC stays on same day
+ ;; For positive offsets > 30min, date rolls forward
+ (should (= 5 (length result)))))
+
+(provide 'test-calendar-sync--convert-utc-to-local)
+;;; test-calendar-sync--convert-utc-to-local.el ends here