From 483e816b5159994d78e0dc14b836012410f764df Mon Sep 17 00:00:00 2001 From: Cedric Date: Sat, 11 Jan 2025 15:41:24 +0100 Subject: [PATCH] Updated default dates --- package.json | 2 +- src/lib/stores/Dates.ts | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 55c167b..53f8c03 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "abmarsch", - "version": "2.0.0", + "version": "2.0.1", "private": true, "scripts": { "dev": "vite dev", diff --git a/src/lib/stores/Dates.ts b/src/lib/stores/Dates.ts index 73ca240..cfbaf30 100644 --- a/src/lib/stores/Dates.ts +++ b/src/lib/stores/Dates.ts @@ -3,8 +3,8 @@ import storedWritable from '@efstajas/svelte-stored-writable' import { z } from 'zod' import { browser } from '$app/environment' -const DEFAULT_START_DATE = new Date('2024-07-01') -const DEFAULT_END_DATE = new Date('2024-11-01') +const DEFAULT_START_DATE = new Date('2025-01-13') +const DEFAULT_END_DATE = new Date('2025-05-16') export const startDate = storedWritable('startDate', z.coerce.date(), DEFAULT_START_DATE, !browser) export const endDate = storedWritable('endDate', z.coerce.date(), DEFAULT_END_DATE, !browser) @@ -16,7 +16,11 @@ export const daysLeft = derived([endDate], ([$endDate]) => { export const daysPassed = derived([startDate], ([$startDate]) => { const diff = new Date().getTime() - $startDate.getTime() - return Math.ceil(diff / (1000 * 3600 * 24)) + if (diff >= 0) { + return Math.ceil(diff / (1000 * 3600 * 24)) + } else { + return Math.floor(diff / (1000 * 3600 * 24)) + } }) export const daysTotal = derived([startDate, endDate], ([$startDate, $endDate]) => {