keystonejs / keystone-classic

Node.js CMS and web app framework
http://v4.keystonejs.com
MIT License
14.65k stars 2.21k forks source link

Can't use Datetime parseFormat without time zone token #4976

Open ontanj opened 4 years ago

ontanj commented 4 years ago

From what I find the time zone is unconditionally appended to the Datetime string before parsing with Moment. This yields all Datetime parseFormats that lack the trailing 'Z' ineffective. Including 5 from the default list.

Behavior

In Model:

Event.add({
  [...]
  date: { type: Types.Datetime, parseFormat: ['YYYY-MM-DD hh:mm'], required: true, initial: true}
  [...]
})

Setting "2019-11-22 17:30" through Admin UI should be valid.

Currently that's invalid, while setting parseFormat: ['YYYY-MM-DD hh:mm Z'] makes the string "2019-11-22 17:30" valid in Admin UI.

Environment

Software Version
Keystone 4.2.1
Node.js 10.16.3