Skip to content

Commit

Permalink
docs: add info on unqualified local datetime strings (#3760)
Browse files Browse the repository at this point in the history
* 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)

* Tweak

---------

Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
  • Loading branch information
MattSidor and colinhacks authored Dec 10, 2024
1 parent f82f817 commit 71a0c33
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,13 @@ datetime.parse("2020-01-01T00:00:00.123+02"); // pass (only offset hours)
datetime.parse("2020-01-01T00:00:00Z"); // pass (Z still supported)
```

Allow unqualified (timezone-less) datetimes with the `local` 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
7 changes: 7 additions & 0 deletions deno/lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,13 @@ datetime.parse("2020-01-01T00:00:00.123+02"); // pass (only offset hours)
datetime.parse("2020-01-01T00:00:00Z"); // pass (Z still supported)
```

Allow unqualified (timezone-less) datetimes with the `local` 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 71a0c33

Please sign in to comment.