From e361a9fd946ae95a28211a0f17a3ad675182fe85 Mon Sep 17 00:00:00 2001 From: Dmitry S Date: Fri, 20 Aug 2021 14:18:34 -0400 Subject: [PATCH] (core) Fix a few issues with parsing of dates in DateEditor. Summary: - With a format like "DD-MM-YYYY" or "DD MMM YYYY", allow parsing dates with two digit year or numeric month (like "16-8-21"). - Interpret two-digit years in the same way for moment parsing and for bootstrap-datepicker. - For partial inputs (like "8/16"), when a format is present, assume that provided parts cover the date, then month, then year (even for a format that starts with year). Test Plan: Expanded a unittest Reviewers: alexmojaki Reviewed By: alexmojaki Subscribers: alexmojaki Differential Revision: https://phab.getgrist.com/D2985 --- app/client/widgets/DateEditor.js | 7 ++-- app/common/parseDate.ts | 70 ++++++++++++++++++++++++-------- 2 files changed, 57 insertions(+), 20 deletions(-) diff --git a/app/client/widgets/DateEditor.js b/app/client/widgets/DateEditor.js index f1352ea6..b9604946 100644 --- a/app/client/widgets/DateEditor.js +++ b/app/client/widgets/DateEditor.js @@ -7,7 +7,7 @@ const dispose = require('../lib/dispose'); const dom = require('../lib/dom'); const kd = require('../lib/koDom'); const TextEditor = require('./TextEditor'); -const { parseDate } = require('app/common/parseDate'); +const { parseDate, TWO_DIGIT_YEAR_THRESHOLD } = require('app/common/parseDate'); // DatePicker unfortunately requires an (not