Skip to content

Commit

Permalink
Updated default dates
Browse files Browse the repository at this point in the history
  • Loading branch information
CediGasser committed Jan 11, 2025
1 parent 51638ac commit 483e816
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "abmarsch",
"version": "2.0.0",
"version": "2.0.1",
"private": true,
"scripts": {
"dev": "vite dev",
Expand Down
10 changes: 7 additions & 3 deletions src/lib/stores/Dates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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]) => {
Expand Down

0 comments on commit 483e816

Please sign in to comment.