Added jotai (#14)

* Added jotai

* cache settings by using jotai state

* use hydrateAtom with SSR

* remove useSettings

* fix test
This commit is contained in:
Doh
2025-01-03 20:50:54 -05:00
committed by GitHub
parent e06e6260ef
commit cb02b3831c
22 changed files with 126 additions and 75 deletions

View File

@@ -9,7 +9,7 @@ export function cn(...inputs: ClassValue[]) {
// get today's date string for timezone
export function getTodayInTimezone(timezone: string): string {
const now = getNow({ timezone });
return d2s({ dateTime: now, format: 'yyyy-MM-dd' });
return d2s({ dateTime: now, format: 'yyyy-MM-dd', timezone });
}
// get datetime object of now
@@ -34,11 +34,11 @@ export function d2t({ dateTime, timezone = 'utc' }: { dateTime: DateTime, timezo
}
// convert datetime object to string, mostly for display
export function d2s({ dateTime, format }: { dateTime: DateTime, format?: string }) {
export function d2s({ dateTime, format, timezone }: { dateTime: DateTime, format?: string, timezone: string }) {
if (format) {
return dateTime.toFormat(format);
return dateTime.setZone(timezone).toFormat(format);
}
return dateTime.toLocaleString(DateTime.DATETIME_MED);
return dateTime.setZone(timezone).toLocaleString(DateTime.DATETIME_MED);
}
// convert datetime object to date string, mostly for display