Skip to content

Commit 38fb8c7

Browse files
committed
docs: update v4 docs to reflect support for HH:MM time format
1 parent 5ae6659 commit 38fb8c7

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/docs/content/api.mdx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ The `z.iso.datetime()` method enforces ISO 8601; by default, no timezone offsets
339339
```ts
340340
const datetime = z.iso.datetime();
341341

342+
datetime.parse("2020-01-01T00:00"); // ✅ (seconds may be omitted if precision is not set)
342343
datetime.parse("2020-01-01T00:00:00Z"); //
343344
datetime.parse("2020-01-01T00:00:00.123Z"); //
344345
datetime.parse("2020-01-01T00:00:00.123456Z"); // ✅ (arbitrary precision)
@@ -355,12 +356,14 @@ datetime.parse("2020-01-01T00:00:00.123+02:00"); // ✅ (millis optional)
355356
datetime.parse("2020-01-01T00:00:00.123+0200"); // ✅ (millis optional)
356357
datetime.parse("2020-01-01T00:00:00.123+02"); // ✅ (only offset hours)
357358
datetime.parse("2020-01-01T00:00:00Z"); // ✅ (Z still supported)
359+
datetime.parse("2020-01-01T00:00Z"); // ✅ (seconds omitted)
358360
```
359361

360362
To allow unqualified (timezone-less) datetimes:
361363

362364
```ts
363365
const schema = z.iso.datetime({ local: true });
366+
schema.parse("2020-01-01T00:00"); //
364367
schema.parse("2020-01-01T00:00:00"); //
365368
```
366369

@@ -370,6 +373,7 @@ To constrain the allowable `precision` (by default, arbitrary sub-second precisi
370373
const datetime = z.iso.datetime({ precision: 3 });
371374

372375
datetime.parse("2020-01-01T00:00:00.123Z"); //
376+
datetime.parse("2020-01-01T00:00Z"); //
373377
datetime.parse("2020-01-01T00:00:00Z"); //
374378
datetime.parse("2020-01-01T00:00:00.123456Z"); //
375379
```
@@ -390,11 +394,12 @@ date.parse("2020-01-32"); // ❌
390394

391395
> Added in Zod 3.23
392396
393-
The `z.iso.time()` method validates strings in the format `HH:MM:SS[.s+]`. The second can include arbitrary decimal precision. It does not allow timezone offsets of any kind.
397+
The `z.iso.time()` method validates strings in the format `HH:MM` or `HH:MM:SS[.s+]`. The second can include arbitrary decimal precision. It does not allow timezone offsets of any kind.
394398

395399
```ts
396400
const time = z.iso.time();
397401

402+
time.parse("00:00"); //
398403
time.parse("00:00:00"); //
399404
time.parse("09:52:31"); //
400405
time.parse("23:59:59.9999999"); // ✅ (arbitrary precision)

0 commit comments

Comments
 (0)