Skip to content

Commit

Permalink
Update README.md with info on unqualified local datetime strings
Browse files Browse the repository at this point in the history
This feature was added in version 3.23.0. (https://github.com/colinhacks/zod/releases/tag/v3.23.0)
  • Loading branch information
MattSidor authored Sep 18, 2024
1 parent 3032e24 commit 264f000
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 264f000

Please # to comment.