Skip to content

Add support for UTC parsing mode#9

Merged
Marsup merged 1 commit into
hapijs:masterfrom
Wenzil:feature/utc-parsing-mode
Apr 18, 2018
Merged

Add support for UTC parsing mode#9
Marsup merged 1 commit into
hapijs:masterfrom
Wenzil:feature/utc-parsing-mode

Conversation

@Wenzil
Copy link
Copy Markdown

@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
Copy Markdown

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.

2 participants