From 264f000b06f0b6717461e4a493aebd9d5a2431ae Mon Sep 17 00:00:00 2001 From: Matt Sidor Date: Wed, 18 Sep 2024 10:00:02 -0700 Subject: [PATCH] Update README.md with info on unqualified local datetime strings This feature was added in version 3.23.0. (https://github.com/colinhacks/zod/releases/tag/v3.23.0) --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index a721693b1..9c6a59aee 100644 --- a/README.md +++ b/README.md @@ -835,6 +835,14 @@ datetime.parse("2020-01-01T00:00:00.123+02"); // pass (only offset hours) datetime.parse("2020-01-01T00:00:00Z"); // pass (Z still supported) ``` +You can allow unqualified (timezone-less) datetimes using the `local: true` flag. + +```ts +const schema = z.string().datetime({ local: true }); + +schema.parse("2020-01-01T00:00:00"); // pass +``` + You can additionally constrain the allowable `precision`. By default, arbitrary sub-second precision is supported (but optional). ```ts