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 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

Sami Turcotte
@Marsup Marsup self-assigned this Apr 18, 2018
@Marsup Marsup added the feature 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
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
security/snyk No dependency changes
Details
Marsup added a commit that referenced this pull request Apr 18, 2018
@Wenzil Wenzil deleted the Wenzil:feature/utc-parsing-mode branch Apr 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.