Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for UTC parsing mode #9

Merged
merged 1 commit into from Apr 18, 2018

Conversation

Wenzil
Copy link

@Wenzil Wenzil commented Apr 6, 2018

When coercing a date string omitting the time part (e.g. YYYY-MM-DD), it was previously always parsed in local time. For example in the EST time zone, 2018-01-01 parsed to 2018-01-01:05:00:00.000Z.

This PR adds an optional utc mode to Joi.date() coercion. Usage:

const schema = Joi.date()
  .utc()
  .format('YYYY-MM-DD');
schema.validate('2018-01-01');

This parses to 2018-01-01:00:00:00.000Z regardless of local time zone

@Marsup Marsup self-assigned this Apr 18, 2018
@Marsup Marsup added the feature New functionality or improvement label Apr 18, 2018
@Marsup Marsup added this to the 1.2.0 milestone Apr 18, 2018
@Marsup Marsup merged commit aabd13c into hapijs:master Apr 18, 2018
Marsup added a commit that referenced this pull request Apr 18, 2018
@Wenzil Wenzil deleted the feature/utc-parsing-mode branch April 21, 2018 23:17
@lock
Copy link

lock bot commented Jan 9, 2020

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature New functionality or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants