add more date range options.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
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";
|
||||
|
||||
interface DateOption {
|
||||
@@ -32,8 +32,8 @@ import EveryMinute from "./EveryMinute.svelte";
|
||||
$: {
|
||||
if (options.length === 0) {
|
||||
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({
|
||||
id: "this_week",
|
||||
@@ -48,6 +48,12 @@ import EveryMinute from "./EveryMinute.svelte";
|
||||
from: startOfWeek(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({
|
||||
id: "last_week",
|
||||
@@ -55,6 +61,12 @@ import EveryMinute from "./EveryMinute.svelte";
|
||||
from: startOfWeek(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({
|
||||
id: "this_month",
|
||||
@@ -69,6 +81,18 @@ import EveryMinute from "./EveryMinute.svelte";
|
||||
from: 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({
|
||||
id: "last_month",
|
||||
@@ -76,6 +100,18 @@ import EveryMinute from "./EveryMinute.svelte";
|
||||
from: 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({
|
||||
id: "this_year",
|
||||
@@ -87,15 +123,27 @@ import EveryMinute from "./EveryMinute.svelte";
|
||||
options.push({
|
||||
id: "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({
|
||||
id: "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({
|
||||
@@ -104,6 +152,8 @@ import EveryMinute from "./EveryMinute.svelte";
|
||||
from: null,
|
||||
to: null,
|
||||
});
|
||||
|
||||
console.log(options);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user