aboutsummaryrefslogtreecommitdiff
path: root/src/lib.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.ts')
-rw-r--r--src/lib.ts14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/lib.ts b/src/lib.ts
index 54dffc5..ad3686d 100644
--- a/src/lib.ts
+++ b/src/lib.ts
@@ -266,6 +266,15 @@ export function getScaleRatio(scale: number, scale2: number){
}
return scale2 / scale;
}
+export function getUnitDiff(date: HistDate, date2: HistDate, scale: number): number {
+ if (scale == DAY_SCALE){
+ return date.getDayDiff(date2);
+ } else if (scale == MONTH_SCALE){
+ return date.getMonthDiff(date2);
+ } else {
+ return date.getYearDiff(date2) / scale;
+ }
+}
// For sending timeline-bound data to BaseLine
export class TimelineState {
@@ -284,12 +293,13 @@ export class TimelineState {
this.endOffset = endOffset;
this.scaleIdx = scaleIdx;
}
-};
+}
export type HistEvent = {
+ id: number,
title: string,
start: HistDate,
startUpper: HistDate | null,
- end: HistDate,
+ end: HistDate | null,
endUpper: HistDate | null,
};