keystone-classic icon indicating copy to clipboard operation
keystone-classic copied to clipboard

Can't use Datetime parseFormat without time zone token

Open ontanj opened this issue 5 years ago • 0 comments

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

ontanj avatar Nov 22 '19 17:11 ontanj