question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

z.date documentation needed

See original GitHub issue

Discussed in https://github.com/colinhacks/zod/discussions/879

<div type='discussions-op-text'>

Originally posted by blocka January 24, 2022 Very surprised that I could not find anything on this.

If I have a date schema const schema = z.date() and I pass it a date string schema.parse('2022-01-12T00:00:00.000Z') I would expect to get back a JS Date object. Instead I get an exception that I’ve passed a string instead of a date. …</div>

There really should be some documentation in the README about how z.date works.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

1reaction
JacobWeisenburgercommented, Jan 25, 2022

I agree completely.

I think the “parse, don’t validate” thing is confusing. I have been using Zod for awhile now and so I get how it works. But I still don’t get the reasoning behind “parse, don’t validate”. To me, leaving the implementation of parse and safeParse the way they are is fine, but renaming them to validate and safeValidate or something would help with some of the confusion. But that’s just me…

0reactions
scotttrinhcommented, Feb 4, 2022

@JacobWeisenburger

Started a discussion to talk about forming a documentation working group if you’re interested: https://github.com/colinhacks/zod/discussions/911

Read more comments on GitHub >

github_iconTop Results From Across the Web

DATE - IBM
You can use the following options to obtain specific date formats. (Only the bold character is needed; all other characters are ignored.).
Read more >
Date and Time Formats - W3C
This profile defines a restricted range of formats, all of which are valid ISO 8601 dates and times. The aim is to simplify...
Read more >
Datetime Patterns for Formatting and Parsing - Apache Spark
Spark uses pattern letters in the following table for date and timestamp parsing and formatting ... z, time-zone name, zone-name, Pacific Standard Time;...
Read more >
Format Dates and Times - MuleSoft Documentation
DataWeave supports the use of formatting characters, such as the u (for the year), M , and d in the date format uuuu-MM-dd...
Read more >
Date and Time Input / Output - Snowflake Documentation
Date & Time Functions. In this Topic: How Snowflake Determines the Input and Output Formats to Use. Session Parameters for Dates, Times, and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found