diff --git a/packages/docs/content/docs/parsers/built-in.mdx b/packages/docs/content/docs/parsers/built-in.mdx index 9dda246b..a5e7ed0c 100644 --- a/packages/docs/content/docs/parsers/built-in.mdx +++ b/packages/docs/content/docs/parsers/built-in.mdx @@ -179,7 +179,7 @@ parseAsStringEnum(Object.values(Direction)) ## Dates & timestamps -There are two parsers that give you a `Date` object, their difference is +There are three parsers that give you a `Date` object, their difference is on how they encode the value into the query string. ### ISO 8601 Datetime @@ -194,8 +194,6 @@ import { parseAsIsoDateTime } from 'nuqs' ### ISO 8601 Date -Note: the Date is parsed without the time zone offset, making it at GMT 00:00:00 UTC. - ```ts import { parseAsIsoDate } from 'nuqs' ``` @@ -204,6 +202,11 @@ import { parseAsIsoDate } from 'nuqs' + + The Date is parsed without the time zone offset, making it at 00:00:00 UTC.
+ _Support: introduced in version 2.1.0._ +
+ ### Timestamp Miliseconds since the Unix epoch. diff --git a/packages/docs/content/docs/parsers/demos.tsx b/packages/docs/content/docs/parsers/demos.tsx index 2429926d..191f0815 100644 --- a/packages/docs/content/docs/parsers/demos.tsx +++ b/packages/docs/content/docs/parsers/demos.tsx @@ -262,16 +262,21 @@ export function DateParserDemo({ { if (e.target.value === '') { setValue(null) } else { - setValue(new Date(e.target.value)) + // Force back the date to UTC to avoid lossy SerDe conversion. + // We could use the valueAsDate, but it's not supported in Chrome. + // See https://github.com/47ng/nuqs/pull/704 + setValue(new Date(e.target.value + 'Z')) } }} /> - UTC + UTC