fix: date picker improvements (#793)

* use vue component for date picker

* zero out database fields even when set to 0001-xx-xx

* fix wrong datetime display + improved datepicker

* fix ts error

* zero out times

* add date-fns to dependencies
This commit is contained in:
Hayden 2024-02-29 12:58:26 -06:00 committed by GitHub
parent c708b1759e
commit 4c9ddac395
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 186 additions and 41 deletions

View file

@ -37,7 +37,7 @@ function ordinalIndicator(num: number) {
}
}
export function fmtDate(value: string | Date, fmt: DateTimeFormat = "human", fmtType: DateTimeType): string {
export function fmtDate(value: string | Date, fmt: DateTimeFormat = "human"): string {
const months = [
"January",
"February",
@ -62,11 +62,6 @@ export function fmtDate(value: string | Date, fmt: DateTimeFormat = "human", fmt
return "";
}
if (fmtType === "date") {
// Offset local time
dt.setHours(dt.getHours() + dt.getTimezoneOffset() / 60);
}
switch (fmt) {
case "relative":
return useTimeAgo(dt).value + useDateFormat(dt, " (YYYY-MM-DD)").value;

View file

@ -38,3 +38,27 @@ export function useTheme(): UseTheme {
return { theme, setTheme };
}
export function useIsDark() {
const theme = useTheme();
const darkthemes = [
"synthwave",
"retro",
"cyberpunk",
"valentine",
"halloween",
"forest",
"aqua",
"black",
"luxury",
"dracula",
"business",
"night",
"coffee",
];
return computed(() => {
return darkthemes.includes(theme.theme.value);
});
}