Skip to content

Year-only iso date string is parsed incorrectly #1247

@kanongil

Description

@kanongil

Context

  • node version: 8.1.4
  • joi version: 10.6.0
  • environment (node, browser): node
  • used with (hapi, standalone, ...): standalone
  • any other relevant information:

What are you trying to achieve or the steps to reproduce ?

Joi.date().iso().validate('2013').value.toISOString();

Which result you had ?

'1970-01-01T00:00:02.013Z'

What did you expect ?

Same output as new Date('2013').toISOString():

'2013-01-01T00:00:00.000Z'

As far as I can tell, it unexpectedly parses it as a timestamp value.

Metadata

Metadata

Assignees

Labels

breaking changesChange that can breaking existing codebugBug or defect

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions