Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(string): Create .datetime()#2087

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
jquense merged 5 commits intojquense:masterfrom0livare:datetime
Feb 28, 2024
Merged

Conversation

0livare
Copy link
Contributor

@0livare0livare commentedAug 16, 2023
edited
Loading

yup.date() always attempts to parse input into aDate object. Sometimes that is undesirable and you just want the string to be left alone. Currently yup does not have a solution for that use case, but that's where.datetime() comes in!

With an API inspired byzod.datetime,datetime also provides greater control over the exact required format of the ISO string thandate does.

@0livare
Copy link
ContributorAuthor

@jquense is this something you would consider?


Unlike `.date()`, `datetime` will not convert the string to a `Date` object. `datetime` also provides greater customization over the required format of the datetime string than `date` does.

`options.allowOffset`: Allow a time zone offset. False requires UTC 'Z' timezone. _(default: false)_
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

why default to false for this?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

My thinking was that most of the time when you store an iso date in a DB (which in my mind will be the most common use case for this function) you would want them to be consistently formatted in UTC time for easy comparison.

src/string.ts Outdated
/** Allow a time zone offset. False requires UTC 'Z' timezone. (default: false) */
allowOffset?: boolean | null;
/** Require a certain sub-second precision on the date. (default: null -- any or no sub-second precision) */
precision?: number | null;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

i'd have both of these options not be nullable

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Done!

@jquense
Copy link
Owner

yes open to this 👍

0livare and haikyuu reacted with rocket emoji

@0livare
Copy link
ContributorAuthor

@jquense Just a heads up that I believe I have addressed both of your comments!

@jquense
Copy link
Owner

@0livare sorry this is taking so long but can you fix the build?

This will allow us to reuse the date struct for .datetime()
undefined is now the default value for precision, which I think makessense because it indicates that the precision is "not defined", andtherefore can have any or zero digits of precision.
@0livare
Copy link
ContributorAuthor

0livare commentedFeb 14, 2024
edited
Loading

@jquense build is fixed! (no changes, I just rebased onto the latest master)

@jquensejquense merged commit2a9e060 intojquense:masterFeb 28, 2024
@jquense
Copy link
Owner

thanks!

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@jquensejquensejquense approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@0livare@jquense

[8]ページ先頭

©2009-2025 Movatter.jp