fix(dates): invalid UTC in RRULE
This commit is contained in:
@@ -1,6 +1,22 @@
|
||||
import { formatDistanceToNow } from "date-fns";
|
||||
import { enUS, fr } from "date-fns/locale";
|
||||
|
||||
export function parseDateInput(rawDate: string): Date {
|
||||
const parts = rawDate.split('-').map(part => parseInt(part, 10));
|
||||
if (!parts[0] || !parts[1] || !parts[2]) {
|
||||
return new Date(new Date().setHours(0, 0, 0, 0))
|
||||
}
|
||||
return new Date(parts[0], parts[1] - 1, parts[2]);
|
||||
}
|
||||
|
||||
export function formatDateInput(date: Date): string {
|
||||
return [
|
||||
date.getFullYear().toFixed(0),
|
||||
(date.getMonth() + 1).toFixed(0).padStart(2, '0'),
|
||||
(date.getDate()).toFixed(0).padStart(2, '0'),
|
||||
].join('-');
|
||||
}
|
||||
|
||||
export function relativeTime(date: Date, locale: string): string {
|
||||
return formatDistanceToNow(date, {
|
||||
addSuffix: true,
|
||||
|
||||
Reference in New Issue
Block a user