From 6de688df96e15e55dce189533d7b7c1c84a77154 Mon Sep 17 00:00:00 2001 From: Furkan Sahin Date: Wed, 1 Jun 2022 10:41:57 -0500 Subject: Compute duration of an event based on { start, end, days } --- src/models/EventInfo.ts | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/models/EventInfo.ts') diff --git a/src/models/EventInfo.ts b/src/models/EventInfo.ts index a6819db..693c8bb 100644 --- a/src/models/EventInfo.ts +++ b/src/models/EventInfo.ts @@ -57,4 +57,10 @@ export default class EventInfo { return `${this.days} ${EventInfo.timeToStr(this.start)}-${EventInfo.timeToStr(this.end)}`; } } + + get duration_mins() { + const diff_hours = Math.floor(this.end / 100) - Math.floor(this.start / 100); + const diff_mins = this.end % 100 - this.start % 100; + return (diff_hours * 60 + diff_mins) * this.days.length; + } } \ No newline at end of file -- cgit v1.2.3