diff --git a/components/calendar/view/Row.vue b/components/calendar/view/Row.vue
index baa16966..bb32e328 100644
--- a/components/calendar/view/Row.vue
+++ b/components/calendar/view/Row.vue
@@ -1,7 +1,7 @@
- Duration
+
@@ -24,6 +24,40 @@ export default Vue.extend({
type: Object as () => Marathon,
default: undefined,
},
+ datetime: {
+ type: String,
+ // The Date() function returns a string denoting "now"
+ default: () => Date(),
+ },
+ },
+
+ computed: {
+ start(): number {
+ return this.todayStart < this.marathonStart ? this.getHoursFraction(this.marathonStart) : 0;
+ },
+ end(): number {
+ return this.todayEnd > this.marathonEnd ? this.getHoursFraction(this.marathonEnd) : 24;
+ },
+ todayStart(): Date {
+ return new Date(this.datetime);
+ },
+ todayEnd(): Date {
+ const todayEnd = new Date(this.todayStart);
+ todayEnd.setDate(this.todayStart.getDate() + 1);
+ return todayEnd;
+ },
+ marathonStart(): Date {
+ return new Date(this.marathon.startDate);
+ },
+ marathonEnd(): Date {
+ return new Date(this.marathon.endDate);
+ },
+ },
+
+ methods: {
+ getHoursFraction(date: Date): number {
+ return date.getHours() + date.getMinutes() / 60;
+ },
},
});
diff --git a/components/calendar/view/View.vue b/components/calendar/view/View.vue
index 2c76d9b6..3b4a1801 100644
--- a/components/calendar/view/View.vue
+++ b/components/calendar/view/View.vue
@@ -12,7 +12,7 @@
-
+
@@ -117,7 +117,7 @@ export default Vue.extend({
getMarathons(day: number): Array|undefined {
const dayStart = new Date(this.year, this.month - 1, day);
const dayEnd = new Date(this.year, this.month - 1, day + 1);
- return this.calendar?.calendar?.filter(marathon => new Date(marathon.endDate) >= dayStart && new Date(marathon.startDate) <= dayEnd);
+ return this.calendar?.calendar?.filter(marathon => new Date(marathon.endDate) > dayStart && new Date(marathon.startDate) < dayEnd);
},
getClasses(marathon: Marathon, index: number): { 'is-primary': boolean, 'is-even': boolean, 'is-odd': boolean } {
const now = new Date();