From 4a0ffc55734adaaf3e9eacd9ee4bbc212e96a71e Mon Sep 17 00:00:00 2001
From: Terry Truong <terry06890@gmail.com>
Date: Fri, 14 Oct 2022 17:52:29 +1100
Subject: Account for there being no year 0 CE

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

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

diff --git a/src/components/TimeLine.vue b/src/components/TimeLine.vue
index 01c937c..8c0bbb3 100644
--- a/src/components/TimeLine.vue
+++ b/src/components/TimeLine.vue
@@ -123,7 +123,7 @@ function initScale(){
 }
 function getYearlyScale(startDate: HistDate, endDate: HistDate, availLen: number){
 	// Get the smallest yearly scale that divides a date range, without making ticks too close
-	let yearDiff = endDate.year - startDate.year;
+	let yearDiff = startDate.getYearDiff(endDate);
 	let idx = 0;
 	while (SCALES[idx] >= yearDiff){ // Get scale with units smaller than yearDiff
 		idx += 1;
@@ -160,7 +160,7 @@ function getNumVisibleUnits(): number {
 	} else if (scale.value == MONTH_SCALE){
 		numUnits = startDate.value.getMonthDiff(endDate.value);
 	} else {
-		numUnits = (endDate.value.year - startDate.value.year) / scale.value;
+		numUnits = startDate.value.getYearDiff(endDate.value) / scale.value;
 	}
 	return numUnits + startOffset.value + endOffset.value;
 }
-- 
cgit v1.2.3

