|
@ -1,6 +1,6 @@ |
|
|
<script lang="ts"> |
|
|
<script lang="ts"> |
|
|
import { onMount } from "svelte"; |
|
|
import { onMount } from "svelte"; |
|
|
import { endOfMonth, endOfWeek, endOfYear, formatFormTime, lastMonth, monthName, nextMonth, startOfMonth, startOfWeek, startOfYear } from "../utils/time"; |
|
|
|
|
|
|
|
|
import { endOfDay, endOfMonth, endOfWeek, endOfYear, formatFormTime, lastMonth, lastYear, monthName, nextMonth, nextYear, startOfDay, startOfMonth, startOfWeek, startOfYear } from "../utils/time"; |
|
|
import EveryMinute from "./EveryMinute.svelte"; |
|
|
import EveryMinute from "./EveryMinute.svelte"; |
|
|
|
|
|
|
|
|
interface DateOption { |
|
|
interface DateOption { |
|
@ -32,8 +32,8 @@ import EveryMinute from "./EveryMinute.svelte"; |
|
|
$: { |
|
|
$: { |
|
|
if (options.length === 0) { |
|
|
if (options.length === 0) { |
|
|
let current = startOfMonth(now); |
|
|
let current = startOfMonth(now); |
|
|
const nextWeek = new Date(Date.now() + (86400000 * 7)); |
|
|
|
|
|
const lastWeek = new Date(Date.now() - (86400000 * 7)); |
|
|
|
|
|
|
|
|
const nextWeek = new Date(now.getTime() + (86400000 * 7)); |
|
|
|
|
|
const lastWeek = new Date(now.getTime() - (86400000 * 7)); |
|
|
|
|
|
|
|
|
options.push({ |
|
|
options.push({ |
|
|
id: "this_week", |
|
|
id: "this_week", |
|
@ -48,6 +48,12 @@ import EveryMinute from "./EveryMinute.svelte"; |
|
|
from: startOfWeek(nextWeek), |
|
|
from: startOfWeek(nextWeek), |
|
|
to: endOfWeek(nextWeek), |
|
|
to: endOfWeek(nextWeek), |
|
|
}); |
|
|
}); |
|
|
|
|
|
options.push({ |
|
|
|
|
|
id: "next_7days", |
|
|
|
|
|
label: "Next 7 Days", |
|
|
|
|
|
from: startOfDay(now), |
|
|
|
|
|
to: endOfDay(new Date(now.getTime() + 86400000 * 7)), |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
options.push({ |
|
|
options.push({ |
|
|
id: "last_week", |
|
|
id: "last_week", |
|
@ -55,6 +61,12 @@ import EveryMinute from "./EveryMinute.svelte"; |
|
|
from: startOfWeek(lastWeek), |
|
|
from: startOfWeek(lastWeek), |
|
|
to: endOfWeek(lastWeek), |
|
|
to: endOfWeek(lastWeek), |
|
|
}); |
|
|
}); |
|
|
|
|
|
options.push({ |
|
|
|
|
|
id: "last_7days", |
|
|
|
|
|
label: "Last 7 Days", |
|
|
|
|
|
from: startOfDay(new Date(now.getTime() - 86400000 * 7)), |
|
|
|
|
|
to: endOfDay(now), |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
options.push({ |
|
|
options.push({ |
|
|
id: "this_month", |
|
|
id: "this_month", |
|
@ -69,6 +81,18 @@ import EveryMinute from "./EveryMinute.svelte"; |
|
|
from: nextMonth(current), |
|
|
from: nextMonth(current), |
|
|
to: endOfMonth(nextMonth(current)), |
|
|
to: endOfMonth(nextMonth(current)), |
|
|
}); |
|
|
}); |
|
|
|
|
|
options.push({ |
|
|
|
|
|
id: "next_30days", |
|
|
|
|
|
label: "Next 30 Days", |
|
|
|
|
|
from: startOfDay(now), |
|
|
|
|
|
to: endOfDay(new Date(now.getTime() + 86400000 * 30)), |
|
|
|
|
|
}); |
|
|
|
|
|
options.push({ |
|
|
|
|
|
id: "next_90days", |
|
|
|
|
|
label: "Next 90 Days", |
|
|
|
|
|
from: startOfDay(now), |
|
|
|
|
|
to: endOfDay(new Date(now.getTime() + 86400000 * 90)), |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
options.push({ |
|
|
options.push({ |
|
|
id: "last_month", |
|
|
id: "last_month", |
|
@ -76,6 +100,18 @@ import EveryMinute from "./EveryMinute.svelte"; |
|
|
from: lastMonth(current), |
|
|
from: lastMonth(current), |
|
|
to: endOfMonth(lastMonth(current)), |
|
|
to: endOfMonth(lastMonth(current)), |
|
|
}); |
|
|
}); |
|
|
|
|
|
options.push({ |
|
|
|
|
|
id: "last_30days", |
|
|
|
|
|
label: "Last 30 Days", |
|
|
|
|
|
from: startOfDay(new Date(now.getTime() - 86400000 * 30)), |
|
|
|
|
|
to: endOfDay(now), |
|
|
|
|
|
}); |
|
|
|
|
|
options.push({ |
|
|
|
|
|
id: "last_90days", |
|
|
|
|
|
label: "Last 90 Days", |
|
|
|
|
|
from: startOfDay(new Date(now.getTime() - 86400000 * 90)), |
|
|
|
|
|
to: endOfDay(now), |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
options.push({ |
|
|
options.push({ |
|
|
id: "this_year", |
|
|
id: "this_year", |
|
@ -87,15 +123,27 @@ import EveryMinute from "./EveryMinute.svelte"; |
|
|
options.push({ |
|
|
options.push({ |
|
|
id: "next_year", |
|
|
id: "next_year", |
|
|
label: "Next Year", |
|
|
label: "Next Year", |
|
|
from: startOfYear(new Date(Date.now() + (366.25 * 86400000))), |
|
|
|
|
|
to: endOfYear(new Date(Date.now() + (365.25 * 86400000))), |
|
|
|
|
|
|
|
|
from: startOfYear(nextYear(now)), |
|
|
|
|
|
to: endOfYear(nextYear(now, 2)), |
|
|
|
|
|
}); |
|
|
|
|
|
options.push({ |
|
|
|
|
|
id: "next_1year", |
|
|
|
|
|
label: "Next 1 Year", |
|
|
|
|
|
from: startOfDay(now), |
|
|
|
|
|
to: endOfDay(nextYear(now)), |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
options.push({ |
|
|
options.push({ |
|
|
id: "last_year", |
|
|
id: "last_year", |
|
|
label: "Last Year", |
|
|
label: "Last Year", |
|
|
from: startOfYear(new Date(Date.now() - (365.25 * 86400000))), |
|
|
|
|
|
to: endOfYear(new Date(Date.now() - (365.25 * 86400000))), |
|
|
|
|
|
|
|
|
from: startOfYear(lastYear(now)), |
|
|
|
|
|
to: endOfYear(lastYear(now)), |
|
|
|
|
|
}); |
|
|
|
|
|
options.push({ |
|
|
|
|
|
id: "last_1year", |
|
|
|
|
|
label: "Last 1 Year", |
|
|
|
|
|
from: startOfDay(lastYear(now)), |
|
|
|
|
|
to: endOfDay(now), |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
options.push({ |
|
|
options.push({ |
|
@ -104,6 +152,8 @@ import EveryMinute from "./EveryMinute.svelte"; |
|
|
from: null, |
|
|
from: null, |
|
|
to: null, |
|
|
to: null, |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
console.log(options); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|