From f06321dea2738e339f83c8cc08e9fa829e0da0d4 Mon Sep 17 00:00:00 2001
From: Terry Truong <terry06890@gmail.com>
Date: Sat, 15 Oct 2022 12:56:01 +1100
Subject: Fix more bugs due to not excluding 0 CE

---
 src/components/TimeLine.vue | 9 +++++++++
 1 file changed, 9 insertions(+)

(limited to 'src/components/TimeLine.vue')

diff --git a/src/components/TimeLine.vue b/src/components/TimeLine.vue
index 0c0e6d6..8301dba 100644
--- a/src/components/TimeLine.vue
+++ b/src/components/TimeLine.vue
@@ -414,6 +414,8 @@ function zoomTimeline(zoomRatio: number){
 			newStartOffset /= oldUnitsPerNew;
 			newEndOffset /= oldUnitsPerNew;
 			// Shift starting and ending points to align with new scale
+				// Note: There is some distortion due to not accounting for no year 0 CE here
+					// But the result seems tolerable, and resolving it adds a fair bit of code complexity
 			let newStartSubUnits =
 				(scale.value == DAY_SCALE) ? getDaysInMonth(newStart.year, newStart.month) :
 				(scale.value == MONTH_SCALE) ? 12 :
@@ -455,6 +457,13 @@ function zoomTimeline(zoomRatio: number){
 			} else {
 				newStart.year = Math.floor(newStart.year / newScale) * newScale;
 				newEnd.year = Math.floor(newEnd.year / newScale) * newScale;
+				// Account for no 0 CE
+				if (newStart.year == 0){
+					newStart.year = 1;
+				}
+				if (newEnd.year == 0){
+					newEnd.year = 1;
+				}
 			}
 			//
 			scaleIdx.value -= 1;
-- 
cgit v1.2.3

