Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.
Go dockerfossgomarkdownmemomicroblognote-takingnotesopen-sourceown-your-datareactself-hostedsqlitetimeline
fix: dayjs - ISO 8601 compatible DATE_TIME_FORMAT (#4829)
unuunn8732575ea40c
diff --git a/web/src/components/DateTimeInput.tsx b/web/src/components/DateTimeInput.tsxindex a1901be05..6d0c126fc 100644--- a/web/src/components/DateTimeInput.tsx+++ b/web/src/components/DateTimeInput.tsx@@ -2,7 +2,8 @@ import dayjs from "dayjs";import toast from "react-hot-toast";import { cn } from "@/lib/utils";-const DATE_TIME_FORMAT = "M/D/YYYY, H:mm:ss";+// must be compatible with JS Date.parse(), we use ISO 8601 (almost)+const DATE_TIME_FORMAT = "YYYY-MM-DD HH:mm:ss";// convert Date to datetime string.const formatDate = (date: Date): string => {@@ -23,12 +24,13 @@ const DateTimeInput: React.FC<Props> = ({ value, onChange }) => {onBlur={(e) => {const inputValue = e.target.value;if (inputValue) {- const date = dayjs(inputValue, DATE_TIME_FORMAT, true).toDate();+ // note: inputValue must be compatible with JS Date.parse()+ const date = dayjs(inputValue).toDate();// Check if the date is valid.if (!isNaN(date.getTime())) {onChange(date);} else {- toast.error("Invalid datetime format. Use format: 12/31/2023, 23:59:59");+ toast.error("Invalid datetime format. Use format: 2023-12-31 23:59:59");e.target.value = formatDate(value);}}