From 226c8725ff92e4055dfedd46d98465a896c15803 Mon Sep 17 00:00:00 2001 From: Arghadeep Bosu <115865315+arghaDEVIL@users.noreply.github.com> Date: Fri, 12 Jan 2024 17:00:41 +0530 Subject: [PATCH 1/3] Update Home.vue updated the code so that the countdown always displays 2 digits and added a hover effect to the login and discord buttons --- src/views/Home.vue | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/views/Home.vue b/src/views/Home.vue index b06e5ba..90f94c9 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -6,7 +6,14 @@ - +

Aperta Fons

@@ -29,15 +36,19 @@

The contest is now live until

- {{days}} Days - {{hours}} Hours - {{mins}} Minutes - {{secs}} Seconds + + {{ String(days).padStart(2, '0') }} Days + + + {{ String(hours).padStart(2, '0') }} Hours + + + {{ String(mins).padStart(2, '0') }} Minutes + + + {{ String(secs).padStart(2, '0') }} Seconds + +
From f29595437052ac6e174ee1fa8eef73f7f783b998 Mon Sep 17 00:00:00 2001 From: Arghadeep Bosu <115865315+arghaDEVIL@users.noreply.github.com> Date: Mon, 15 Jan 2024 20:02:47 +0530 Subject: [PATCH 2/3] Update Home.vue --- src/views/Home.vue | 46 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/src/views/Home.vue b/src/views/Home.vue index 90f94c9..9310a14 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -5,15 +5,6 @@ - -

Aperta Fons

@@ -36,6 +27,7 @@

The contest is now live until

+ {{ String(days).padStart(2, '0') }} Days @@ -47,6 +39,7 @@ {{ String(secs).padStart(2, '0') }} Seconds + // this code will always show 2 digits in the timer even when it is less than 10
@@ -437,6 +430,41 @@ export default { return {days, hours, mins, secs, user}; }, }; +// code to prevent negative timer + export default { + data() { + return { + days: 0, + hours: 0, + mins: 0, + secs: 0, + eventDate: new Date('2024-01-05T12:00:00'), // Updated event date to January 5th + }; + }, + mounted() { + this.updateTimer(); + setInterval(this.updateTimer, 1000); // Update every second + }, + methods: { + updateTimer() { + const currentDate = new Date(); + const timeDifference = this.eventDate - currentDate; + + if (timeDifference < 0) { + // Event has ended + this.days = 0; + this.hours = 0; + this.mins = 0; + this.secs = 0; + } else { + this.days = Math.floor(timeDifference / (1000 * 60 * 60 * 24)); + this.hours = Math.floor((timeDifference % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); + this.mins = Math.floor((timeDifference % (1000 * 60 * 60)) / (1000 * 60)); + this.secs = Math.floor((timeDifference % (1000 * 60)) / 1000); + } + }, + }, +};