@beinformed/ui 1.59.3 → 1.59.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/esm/models/attributes/DatetimeAttributeModel.js +30 -6
- package/esm/models/attributes/DatetimeAttributeModel.js.map +1 -1
- package/esm/utils/datetime/DateTimeUtil.js +25 -16
- package/esm/utils/datetime/DateTimeUtil.js.map +1 -1
- package/lib/models/attributes/DatetimeAttributeModel.js +30 -6
- package/lib/models/attributes/DatetimeAttributeModel.js.flow +32 -5
- package/lib/models/attributes/DatetimeAttributeModel.js.map +1 -1
- package/lib/models/attributes/__tests__/DateAttributeModel.spec.js.flow +17 -0
- package/lib/models/attributes/__tests__/DatetimeAttributeModel_offset.spec.js.flow +17 -0
- package/lib/utils/datetime/DateTimeUtil.js +25 -16
- package/lib/utils/datetime/DateTimeUtil.js.flow +24 -13
- package/lib/utils/datetime/DateTimeUtil.js.map +1 -1
- package/lib/utils/datetime/__tests__/DateTimeFormat.spec.js.flow +5 -0
- package/package.json +1 -1
- package/src/models/attributes/DatetimeAttributeModel.js +32 -5
- package/src/models/attributes/__tests__/DateAttributeModel.spec.js +17 -0
- package/src/models/attributes/__tests__/DatetimeAttributeModel_offset.spec.js +17 -0
- package/src/utils/datetime/DateTimeUtil.js +24 -13
- package/src/utils/datetime/__tests__/DateTimeFormat.spec.js +5 -0
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
|
|
9
9
|
var _trim = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/trim"));
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
10
11
|
var _objects = require("../../utils/helpers/objects");
|
|
11
12
|
var _DateTimeUtil = require("../../utils/datetime/DateTimeUtil");
|
|
12
13
|
var _StringAttributeModel = _interopRequireDefault(require("./StringAttributeModel"));
|
|
@@ -23,6 +24,8 @@ class DatetimeAttributeModel extends _StringAttributeModel.default {
|
|
|
23
24
|
*/
|
|
24
25
|
constructor(attribute, attributeContributions, modelOptions) {
|
|
25
26
|
super(attribute, attributeContributions, modelOptions);
|
|
27
|
+
(0, _defineProperty2.default)(this, "_dateInputFormat", void 0);
|
|
28
|
+
(0, _defineProperty2.default)(this, "_timeInputFormat", void 0);
|
|
26
29
|
this.updateInitValue();
|
|
27
30
|
}
|
|
28
31
|
|
|
@@ -213,21 +216,38 @@ class DatetimeAttributeModel extends _StringAttributeModel.default {
|
|
|
213
216
|
/**
|
|
214
217
|
*/
|
|
215
218
|
get dateInputFormat() {
|
|
216
|
-
var _context7;
|
|
217
219
|
if (!this.hasDate) {
|
|
218
220
|
return "";
|
|
219
221
|
}
|
|
220
|
-
|
|
222
|
+
if (this._dateInputFormat) {
|
|
223
|
+
return this._dateInputFormat;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// remove time and offset tokens
|
|
227
|
+
const charsToRemove = "HhaKmsSzXxO:";
|
|
228
|
+
let inputFormat = "";
|
|
229
|
+
let isInQuotes = false;
|
|
230
|
+
for (let i = 0; i < this.format.length; i++) {
|
|
231
|
+
const char = this.format[i];
|
|
232
|
+
if (char === "'") {
|
|
233
|
+
isInQuotes = !isInQuotes;
|
|
234
|
+
}
|
|
235
|
+
if (isInQuotes || !(0, _includes.default)(charsToRemove).call(charsToRemove, char)) {
|
|
236
|
+
inputFormat += char;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
this._dateInputFormat = (0, _trim.default)(inputFormat).call(inputFormat);
|
|
240
|
+
return this._dateInputFormat;
|
|
221
241
|
}
|
|
222
242
|
|
|
223
243
|
/**
|
|
224
244
|
*/
|
|
225
245
|
get dateReadonlyFormat() {
|
|
226
|
-
var
|
|
246
|
+
var _context7;
|
|
227
247
|
if (!this.hasDate) {
|
|
228
248
|
return "";
|
|
229
249
|
}
|
|
230
|
-
return this.hasTime ? (0, _trim.default)(
|
|
250
|
+
return this.hasTime ? (0, _trim.default)(_context7 = this.format.replace(this.timeInputFormat, "")).call(_context7) : this.format;
|
|
231
251
|
}
|
|
232
252
|
|
|
233
253
|
/**
|
|
@@ -258,6 +278,9 @@ class DatetimeAttributeModel extends _StringAttributeModel.default {
|
|
|
258
278
|
if (!this.hasTime) {
|
|
259
279
|
return "";
|
|
260
280
|
}
|
|
281
|
+
if (this._timeInputFormat) {
|
|
282
|
+
return this._timeInputFormat;
|
|
283
|
+
}
|
|
261
284
|
const format = this.format;
|
|
262
285
|
let timeFormatParts = [];
|
|
263
286
|
if ((0, _includes.default)(format).call(format, "H")) {
|
|
@@ -276,9 +299,10 @@ class DatetimeAttributeModel extends _StringAttributeModel.default {
|
|
|
276
299
|
timeFormat = `${timeFormat}.SSS`;
|
|
277
300
|
}
|
|
278
301
|
if ((0, _includes.default)(format).call(format, "a")) {
|
|
279
|
-
|
|
302
|
+
timeFormat = `${timeFormat} a`;
|
|
280
303
|
}
|
|
281
|
-
|
|
304
|
+
this._timeInputFormat = timeFormat;
|
|
305
|
+
return this._timeInputFormat;
|
|
282
306
|
}
|
|
283
307
|
|
|
284
308
|
/**
|
|
@@ -34,6 +34,9 @@ import type { OffsetInfo } from "../../utils/datetime/DateTimeUtil";
|
|
|
34
34
|
/**
|
|
35
35
|
*/
|
|
36
36
|
class DatetimeAttributeModel extends StringAttributeModel {
|
|
37
|
+
_dateInputFormat: ?string;
|
|
38
|
+
_timeInputFormat: ?string;
|
|
39
|
+
|
|
37
40
|
/**
|
|
38
41
|
*/
|
|
39
42
|
constructor(
|
|
@@ -269,9 +272,27 @@ class DatetimeAttributeModel extends StringAttributeModel {
|
|
|
269
272
|
return "";
|
|
270
273
|
}
|
|
271
274
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
+
if (this._dateInputFormat) {
|
|
276
|
+
return this._dateInputFormat;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// remove time and offset tokens
|
|
280
|
+
const charsToRemove = "HhaKmsSzXxO:";
|
|
281
|
+
|
|
282
|
+
let inputFormat = "";
|
|
283
|
+
let isInQuotes = false;
|
|
284
|
+
for (let i = 0; i < this.format.length; i++) {
|
|
285
|
+
const char = this.format[i];
|
|
286
|
+
if (char === "'") {
|
|
287
|
+
isInQuotes = !isInQuotes;
|
|
288
|
+
}
|
|
289
|
+
if (isInQuotes || !charsToRemove.includes(char)) {
|
|
290
|
+
inputFormat += char;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
this._dateInputFormat = inputFormat.trim();
|
|
295
|
+
return this._dateInputFormat;
|
|
275
296
|
}
|
|
276
297
|
|
|
277
298
|
/**
|
|
@@ -318,6 +339,10 @@ class DatetimeAttributeModel extends StringAttributeModel {
|
|
|
318
339
|
return "";
|
|
319
340
|
}
|
|
320
341
|
|
|
342
|
+
if (this._timeInputFormat) {
|
|
343
|
+
return this._timeInputFormat;
|
|
344
|
+
}
|
|
345
|
+
|
|
321
346
|
const format = this.format;
|
|
322
347
|
|
|
323
348
|
let timeFormatParts = [];
|
|
@@ -338,9 +363,11 @@ class DatetimeAttributeModel extends StringAttributeModel {
|
|
|
338
363
|
timeFormat = `${timeFormat}.SSS`;
|
|
339
364
|
}
|
|
340
365
|
if (format.includes("a")) {
|
|
341
|
-
|
|
366
|
+
timeFormat = `${timeFormat} a`;
|
|
342
367
|
}
|
|
343
|
-
|
|
368
|
+
|
|
369
|
+
this._timeInputFormat = timeFormat;
|
|
370
|
+
return this._timeInputFormat;
|
|
344
371
|
}
|
|
345
372
|
|
|
346
373
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatetimeAttributeModel.js","names":["_objects","require","_DateTimeUtil","_StringAttributeModel","_interopRequireDefault","_ConstraintCollection","_DateTimeDateFormatConstraint","_DateTimeTimeFormatConstraint","_DatetimeFormatConstraint","_DateBoundaryConstraint","_constants","DatetimeAttributeModel","StringAttributeModel","constructor","attribute","attributeContributions","modelOptions","updateInitValue","isApplicableModel","contributions","_context","_includes","default","call","type","formatUtil","TimeUtil","TimestampUtil","DateTimeUtil","DateUtil","getInitValue","value","data","length","toFormat","getIsoFormat","toISO","hasTime","getTimeValue","_context2","_context3","_context4","_context5","timeValue","timeInputFormat","toLowerCase","setHour","setMinute","setSecond","setMilliseconds","isIncludeTimeOffsetInDateTimes","oldOffset","DATETIME_OFFSET_FORMAT","newOffset","replace","_initvalue","_inputvalue","getInitialInputValue","_value","initValue","inputFormat","getContribution","getInputValue","toString","inputvalue","validate","format","convertFormat","hasDate","formatLabel","dateInputFormat","inputFormatWithoutOffset","_context6","_trim","_context7","dateReadonlyFormat","_context8","placeholder","_placeholder","split","timeFormatParts","push","timeFormat","join","timeReadonlyFormat","dateInputValue","timeInputValue","formatValue","hasFormat","ISO_DATE_FORMAT","readonlyvalue","isAmbiguous","offset","getOffset","mindate","maxdate","addServerError","error","id","message","properties","layouthint","has","_errorCollection","getFormatConstraint","DateTimeDateFormatConstraint","DateTimeTimeFormatConstraint","DatetimeFormatConstraint","addConstraints","constraints","ConstraintCollection","add","DateBoundaryConstraint","readonlyWidth","ATTRIBUTE_WIDTH","SMALL","MEDIUM","updateByAttribute","otherAttribute","reset","otherValue","inputValue","update","console","_default","exports"],"sources":["../../../src/models/attributes/DatetimeAttributeModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport {\n DateUtil,\n DateTimeUtil,\n TimeUtil,\n TimestampUtil,\n} from \"../../utils/datetime/DateTimeUtil\";\n\nimport StringAttributeModel from \"./StringAttributeModel\";\n\nimport ConstraintCollection from \"./input-constraints/ConstraintCollection\";\nimport DateTimeDateFormatConstraint from \"./input-constraints/DateTimeDateFormatConstraint\";\nimport DateTimeTimeFormatConstraint from \"./input-constraints/DateTimeTimeFormatConstraint\";\nimport DatetimeFormatConstraint from \"./input-constraints/DatetimeFormatConstraint\";\nimport DateBoundaryConstraint from \"./input-constraints/DateBoundaryConstraint\";\n\nimport {\n isIncludeTimeOffsetInDateTimes,\n ATTRIBUTE_WIDTH,\n DATETIME_OFFSET_FORMAT,\n ISO_DATE_FORMAT,\n} from \"../../constants\";\n\nimport type {\n FormErrorAnchor,\n IConstraintModel,\n AttributeType,\n ModelOptions,\n} from \"../types\";\nimport type { OffsetInfo } from \"../../utils/datetime/DateTimeUtil\";\n\n/**\n */\nclass DatetimeAttributeModel extends StringAttributeModel {\n /**\n */\n constructor(\n attribute: Object,\n attributeContributions: Object,\n modelOptions?: ModelOptions,\n ) {\n super(attribute, attributeContributions, modelOptions);\n\n this.updateInitValue();\n }\n\n /**\n */\n static isApplicableModel(contributions: Object): boolean {\n return [\"date\", \"time\", \"datetime\", \"timestamp\"].includes(\n contributions.type,\n );\n }\n\n /**\n */\n get formatUtil():\n | typeof TimeUtil\n | typeof TimestampUtil\n | typeof DateTimeUtil\n | typeof DateUtil {\n switch (this.type) {\n case \"time\":\n return TimeUtil;\n case \"timestamp\":\n return TimestampUtil;\n case \"datetime\":\n return DateTimeUtil;\n default:\n return DateUtil;\n }\n }\n\n /**\n */\n getInitValue(): string | null {\n let value = this.data.value;\n if (value != null) {\n if (this.type === \"time\" && value.length === 5) {\n value = `${value}:00`;\n }\n\n // handle old datetime values, which contained ms\n if (this.type === \"datetime\" && value.includes(\".\")) {\n value = TimestampUtil.toFormat(value, DateTimeUtil.getIsoFormat());\n } else {\n value = this.formatUtil.toISO(value);\n }\n\n if (this.hasTime) {\n value = this.getTimeValue(value);\n }\n }\n\n return value;\n }\n\n /**\n */\n getTimeValue(value: string): string {\n let timeValue = value;\n if (!this.timeInputFormat.toLowerCase().includes(\"h\")) {\n timeValue = this.formatUtil.setHour(value, 0);\n }\n if (!this.timeInputFormat.includes(\"m\")) {\n timeValue = this.formatUtil.setMinute(value, 0);\n }\n if (!this.timeInputFormat.includes(\"s\")) {\n timeValue = this.formatUtil.setSecond(value, 0);\n }\n if (this.type === \"timestamp\" && !this.timeInputFormat.includes(\"S\")) {\n timeValue = this.formatUtil.setMilliseconds(value, 0);\n }\n\n if (isIncludeTimeOffsetInDateTimes()) {\n // https://github.com/date-fns/date-fns/issues/3579\n const oldOffset = this.formatUtil.toFormat(value, DATETIME_OFFSET_FORMAT);\n const newOffset = this.formatUtil.toFormat(\n timeValue,\n DATETIME_OFFSET_FORMAT,\n );\n timeValue = timeValue.replace(newOffset, oldOffset);\n }\n\n return timeValue;\n }\n\n /**\n * Set time in the correct value based on available elements in the time format\n */\n updateInitValue() {\n const value = this.getInitValue();\n if (value != null) {\n this._initvalue = value;\n this._inputvalue = this.getInitialInputValue(value);\n this._value = value;\n }\n }\n\n /**\n * Get initial user input value\n */\n getInitialInputValue(value?: string): string {\n if (!value) {\n return \"\";\n }\n\n let initValue = value;\n if (this.type === \"time\" && value.length === 5) {\n initValue = `${value}:00`;\n }\n\n return this.formatUtil.toFormat(initValue, this.inputFormat);\n }\n\n /**\n * Set type to date\n */\n get type(): string {\n return this.getContribution(\"type\", \"date\");\n }\n\n /**\n * Returns the value as entered by the user. This can differ from the internal iso value that is stored\n */\n getInputValue(): string {\n return this._inputvalue ? this._inputvalue.toString() : \"\";\n }\n\n /**\n * Get input value\n */\n get inputvalue(): string {\n return this.getInputValue();\n }\n\n /**\n * Sets the input value to the value entered by the user\n */\n set inputvalue(value: string) {\n this.validate(value);\n\n this._inputvalue = value;\n\n this.value =\n value !== null && value !== \"\"\n ? this.formatUtil.toISO(value, this.inputFormat)\n : null;\n }\n\n /**\n * Get date format\n */\n get format(): string {\n const format = this.getContribution(\"format\", \"\");\n return this.formatUtil.convertFormat(format);\n }\n\n /**\n */\n get hasDate(): boolean {\n return (\n this.type === \"date\" ||\n this.type === \"datetime\" ||\n this.type === \"timestamp\"\n );\n }\n\n /**\n */\n get hasTime(): boolean {\n return (\n this.type === \"time\" ||\n this.type === \"datetime\" ||\n this.type === \"timestamp\"\n );\n }\n\n /**\n */\n get formatLabel(): string {\n switch (this.type) {\n case \"date\":\n return this.dateInputFormat.toLowerCase();\n case \"time\":\n return this.timeInputFormat.toLowerCase();\n default:\n return this.format.toLowerCase();\n }\n }\n\n /**\n */\n get inputFormatWithoutOffset(): string {\n if (this.hasDate && this.hasTime) {\n return `${this.dateInputFormat} ${this.timeInputFormat}`.trim();\n }\n\n if (this.hasDate) {\n return this.dateInputFormat;\n }\n\n if (this.hasTime) {\n return this.timeInputFormat;\n }\n\n return \"\";\n }\n\n /**\n */\n get inputFormat(): string {\n if (\n isIncludeTimeOffsetInDateTimes() &&\n this.dateInputFormat !== \"\" &&\n this.timeInputFormat !== \"\"\n ) {\n return `${this.inputFormatWithoutOffset} ${DATETIME_OFFSET_FORMAT}`;\n }\n return this.inputFormatWithoutOffset;\n }\n\n /**\n */\n get dateInputFormat(): string {\n if (!this.hasDate) {\n return \"\";\n }\n\n return this.hasTime\n ? this.format.replace(this.timeInputFormat, \"\").trim()\n : this.format;\n }\n\n /**\n */\n get dateReadonlyFormat(): string {\n if (!this.hasDate) {\n return \"\";\n }\n\n return this.hasTime\n ? this.format.replace(this.timeInputFormat, \"\").trim()\n : this.format;\n }\n\n /**\n * return attribute placeholder or return formatlabel without time input format from contributions\n */\n get placeholder(): string {\n if (this._placeholder !== \"\") {\n return this._placeholder;\n }\n\n const formatLabel = this.getContribution(\"formatlabel\", \"\");\n\n if (this.hasDate && this.hasTime && formatLabel.includes(\" \")) {\n // return first part of formatlabel to keep placeholder matching date input\n return formatLabel.split(\" \")[0];\n }\n\n return formatLabel;\n }\n\n /**\n * Set placeholder text\n */\n set placeholder(placeholder: string) {\n this._placeholder = placeholder;\n }\n\n /**\n */\n get timeInputFormat(): string {\n if (!this.hasTime) {\n return \"\";\n }\n\n const format = this.format;\n\n let timeFormatParts = [];\n if (format.includes(\"H\")) {\n timeFormatParts.push(\"HH\");\n } else if (format.includes(\"h\")) {\n timeFormatParts.push(\"hh\");\n }\n if (format.includes(\"m\")) {\n timeFormatParts.push(\"mm\");\n }\n if (format.includes(\"s\")) {\n timeFormatParts.push(\"ss\");\n }\n\n let timeFormat = timeFormatParts.join(\":\");\n if (format.includes(\"S\")) {\n timeFormat = `${timeFormat}.SSS`;\n }\n if (format.includes(\"a\")) {\n return `${timeFormat} a`;\n }\n return timeFormat;\n }\n\n /**\n */\n get timeReadonlyFormat(): string {\n if (!this.hasTime) {\n return \"\";\n }\n\n return this.timeInputFormat;\n }\n\n /**\n */\n get dateInputValue(): string {\n return typeof this.value === \"string\" && this.dateInputFormat !== \"\"\n ? this.formatUtil.toFormat(this.value, this.dateInputFormat)\n : \"\";\n }\n\n /**\n */\n get timeInputValue(): string {\n return typeof this.value === \"string\" && this.timeInputFormat !== \"\"\n ? this.formatUtil.toFormat(this.value, this.timeInputFormat)\n : \"\";\n }\n\n /**\n * format value in readonly rendering\n */\n formatValue(value: ?string): string {\n if (value == null || value.toString() === \"\") {\n return \"\";\n }\n\n // when the value is exactly an iso date, render as date\n if (\n (this.type === \"datetime\" || this.type === \"timestamp\") &&\n DateUtil.hasFormat(value, ISO_DATE_FORMAT)\n ) {\n return DateUtil.toFormat(value, this.dateReadonlyFormat);\n }\n\n return this.formatUtil.toFormat(value, this.format);\n }\n\n /**\n * Retrieve readonly value, the date in the configurated format\n */\n get readonlyvalue(): string {\n if (typeof this.value === \"string\") {\n return this.formatValue(this.value.toString());\n }\n\n return \"\";\n }\n\n /**\n */\n get isAmbiguous(): boolean {\n if (typeof this.value === \"string\") {\n return this.formatUtil.isAmbiguous(this.value);\n }\n return false;\n }\n\n /**\n */\n get offset(): OffsetInfo | null {\n if (typeof this.value === \"string\") {\n return this.formatUtil.getOffset(this.value);\n }\n return null;\n }\n\n /**\n * Get minimum date\n */\n get mindate(): string | null {\n return this.getContribution(\"mindate\");\n }\n\n /**\n * Get maximum date\n */\n get maxdate(): string | null {\n return this.getContribution(\"maxdate\");\n }\n\n /**\n * Registers an error that was received from a server response\n */\n addServerError(error: FormErrorAnchor) {\n const { id, message, properties, layouthint } = error;\n if (properties && has(properties, \"format\") && this.formatLabel) {\n properties.format = this.formatLabel;\n }\n\n this._errorCollection.addServerError(id, message, properties, layouthint);\n }\n\n /**\n */\n getFormatConstraint(): IConstraintModel {\n switch (this.type) {\n case \"date\":\n return new DateTimeDateFormatConstraint(\n this.dateInputFormat,\n this.formatLabel,\n );\n case \"time\":\n return new DateTimeTimeFormatConstraint(\n this.timeInputFormat,\n this.formatLabel,\n );\n default:\n return new DatetimeFormatConstraint(\n this.type,\n this.inputFormat,\n this.formatLabel,\n );\n }\n }\n\n /**\n * Add Date constraints for attribute\n */\n addConstraints(): ConstraintCollection {\n const constraints = new ConstraintCollection();\n\n constraints.add(this.getFormatConstraint());\n\n if (this.mindate || this.maxdate) {\n constraints.add(\n new DateBoundaryConstraint(\n this.type,\n this.mindate,\n this.maxdate,\n this.inputFormat,\n ),\n );\n }\n\n return constraints;\n }\n\n /**\n */\n get readonlyWidth(): $Keys<typeof ATTRIBUTE_WIDTH> {\n if (this.type === \"date\" || this.type === \"time\") {\n return ATTRIBUTE_WIDTH.SMALL;\n }\n\n return ATTRIBUTE_WIDTH.MEDIUM;\n }\n\n /**\n */\n updateByAttribute(otherAttribute: AttributeType): void {\n this.reset();\n if (otherAttribute instanceof DatetimeAttributeModel) {\n const otherValue = otherAttribute.value;\n if (otherValue != null) {\n const inputValue = this.formatUtil.toFormat(\n otherValue,\n this.inputFormat,\n );\n this.update(inputValue);\n }\n } else {\n console.error(\n `update of datetime attribute with ${otherAttribute.type} not supported`,\n );\n }\n }\n}\n\nexport default DatetimeAttributeModel;\n"],"mappings":";;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,aAAA,GAAAD,OAAA;AAOA,IAAAE,qBAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,qBAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,6BAAA,GAAAF,sBAAA,CAAAH,OAAA;AACA,IAAAM,6BAAA,GA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|
+
{"version":3,"file":"DatetimeAttributeModel.js","names":["_objects","require","_DateTimeUtil","_StringAttributeModel","_interopRequireDefault","_ConstraintCollection","_DateTimeDateFormatConstraint","_DateTimeTimeFormatConstraint","_DatetimeFormatConstraint","_DateBoundaryConstraint","_constants","DatetimeAttributeModel","StringAttributeModel","constructor","attribute","attributeContributions","modelOptions","_defineProperty2","default","updateInitValue","isApplicableModel","contributions","_context","_includes","call","type","formatUtil","TimeUtil","TimestampUtil","DateTimeUtil","DateUtil","getInitValue","value","data","length","toFormat","getIsoFormat","toISO","hasTime","getTimeValue","_context2","_context3","_context4","_context5","timeValue","timeInputFormat","toLowerCase","setHour","setMinute","setSecond","setMilliseconds","isIncludeTimeOffsetInDateTimes","oldOffset","DATETIME_OFFSET_FORMAT","newOffset","replace","_initvalue","_inputvalue","getInitialInputValue","_value","initValue","inputFormat","getContribution","getInputValue","toString","inputvalue","validate","format","convertFormat","hasDate","formatLabel","dateInputFormat","inputFormatWithoutOffset","_context6","_trim","_dateInputFormat","charsToRemove","isInQuotes","i","char","dateReadonlyFormat","_context7","placeholder","_placeholder","split","_timeInputFormat","timeFormatParts","push","timeFormat","join","timeReadonlyFormat","dateInputValue","timeInputValue","formatValue","hasFormat","ISO_DATE_FORMAT","readonlyvalue","isAmbiguous","offset","getOffset","mindate","maxdate","addServerError","error","id","message","properties","layouthint","has","_errorCollection","getFormatConstraint","DateTimeDateFormatConstraint","DateTimeTimeFormatConstraint","DatetimeFormatConstraint","addConstraints","constraints","ConstraintCollection","add","DateBoundaryConstraint","readonlyWidth","ATTRIBUTE_WIDTH","SMALL","MEDIUM","updateByAttribute","otherAttribute","reset","otherValue","inputValue","update","console","_default","exports"],"sources":["../../../src/models/attributes/DatetimeAttributeModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport {\n DateUtil,\n DateTimeUtil,\n TimeUtil,\n TimestampUtil,\n} from \"../../utils/datetime/DateTimeUtil\";\n\nimport StringAttributeModel from \"./StringAttributeModel\";\n\nimport ConstraintCollection from \"./input-constraints/ConstraintCollection\";\nimport DateTimeDateFormatConstraint from \"./input-constraints/DateTimeDateFormatConstraint\";\nimport DateTimeTimeFormatConstraint from \"./input-constraints/DateTimeTimeFormatConstraint\";\nimport DatetimeFormatConstraint from \"./input-constraints/DatetimeFormatConstraint\";\nimport DateBoundaryConstraint from \"./input-constraints/DateBoundaryConstraint\";\n\nimport {\n isIncludeTimeOffsetInDateTimes,\n ATTRIBUTE_WIDTH,\n DATETIME_OFFSET_FORMAT,\n ISO_DATE_FORMAT,\n} from \"../../constants\";\n\nimport type {\n FormErrorAnchor,\n IConstraintModel,\n AttributeType,\n ModelOptions,\n} from \"../types\";\nimport type { OffsetInfo } from \"../../utils/datetime/DateTimeUtil\";\n\n/**\n */\nclass DatetimeAttributeModel extends StringAttributeModel {\n _dateInputFormat: ?string;\n _timeInputFormat: ?string;\n\n /**\n */\n constructor(\n attribute: Object,\n attributeContributions: Object,\n modelOptions?: ModelOptions,\n ) {\n super(attribute, attributeContributions, modelOptions);\n\n this.updateInitValue();\n }\n\n /**\n */\n static isApplicableModel(contributions: Object): boolean {\n return [\"date\", \"time\", \"datetime\", \"timestamp\"].includes(\n contributions.type,\n );\n }\n\n /**\n */\n get formatUtil():\n | typeof TimeUtil\n | typeof TimestampUtil\n | typeof DateTimeUtil\n | typeof DateUtil {\n switch (this.type) {\n case \"time\":\n return TimeUtil;\n case \"timestamp\":\n return TimestampUtil;\n case \"datetime\":\n return DateTimeUtil;\n default:\n return DateUtil;\n }\n }\n\n /**\n */\n getInitValue(): string | null {\n let value = this.data.value;\n if (value != null) {\n if (this.type === \"time\" && value.length === 5) {\n value = `${value}:00`;\n }\n\n // handle old datetime values, which contained ms\n if (this.type === \"datetime\" && value.includes(\".\")) {\n value = TimestampUtil.toFormat(value, DateTimeUtil.getIsoFormat());\n } else {\n value = this.formatUtil.toISO(value);\n }\n\n if (this.hasTime) {\n value = this.getTimeValue(value);\n }\n }\n\n return value;\n }\n\n /**\n */\n getTimeValue(value: string): string {\n let timeValue = value;\n if (!this.timeInputFormat.toLowerCase().includes(\"h\")) {\n timeValue = this.formatUtil.setHour(value, 0);\n }\n if (!this.timeInputFormat.includes(\"m\")) {\n timeValue = this.formatUtil.setMinute(value, 0);\n }\n if (!this.timeInputFormat.includes(\"s\")) {\n timeValue = this.formatUtil.setSecond(value, 0);\n }\n if (this.type === \"timestamp\" && !this.timeInputFormat.includes(\"S\")) {\n timeValue = this.formatUtil.setMilliseconds(value, 0);\n }\n\n if (isIncludeTimeOffsetInDateTimes()) {\n // https://github.com/date-fns/date-fns/issues/3579\n const oldOffset = this.formatUtil.toFormat(value, DATETIME_OFFSET_FORMAT);\n const newOffset = this.formatUtil.toFormat(\n timeValue,\n DATETIME_OFFSET_FORMAT,\n );\n timeValue = timeValue.replace(newOffset, oldOffset);\n }\n\n return timeValue;\n }\n\n /**\n * Set time in the correct value based on available elements in the time format\n */\n updateInitValue() {\n const value = this.getInitValue();\n if (value != null) {\n this._initvalue = value;\n this._inputvalue = this.getInitialInputValue(value);\n this._value = value;\n }\n }\n\n /**\n * Get initial user input value\n */\n getInitialInputValue(value?: string): string {\n if (!value) {\n return \"\";\n }\n\n let initValue = value;\n if (this.type === \"time\" && value.length === 5) {\n initValue = `${value}:00`;\n }\n\n return this.formatUtil.toFormat(initValue, this.inputFormat);\n }\n\n /**\n * Set type to date\n */\n get type(): string {\n return this.getContribution(\"type\", \"date\");\n }\n\n /**\n * Returns the value as entered by the user. This can differ from the internal iso value that is stored\n */\n getInputValue(): string {\n return this._inputvalue ? this._inputvalue.toString() : \"\";\n }\n\n /**\n * Get input value\n */\n get inputvalue(): string {\n return this.getInputValue();\n }\n\n /**\n * Sets the input value to the value entered by the user\n */\n set inputvalue(value: string) {\n this.validate(value);\n\n this._inputvalue = value;\n\n this.value =\n value !== null && value !== \"\"\n ? this.formatUtil.toISO(value, this.inputFormat)\n : null;\n }\n\n /**\n * Get date format\n */\n get format(): string {\n const format = this.getContribution(\"format\", \"\");\n return this.formatUtil.convertFormat(format);\n }\n\n /**\n */\n get hasDate(): boolean {\n return (\n this.type === \"date\" ||\n this.type === \"datetime\" ||\n this.type === \"timestamp\"\n );\n }\n\n /**\n */\n get hasTime(): boolean {\n return (\n this.type === \"time\" ||\n this.type === \"datetime\" ||\n this.type === \"timestamp\"\n );\n }\n\n /**\n */\n get formatLabel(): string {\n switch (this.type) {\n case \"date\":\n return this.dateInputFormat.toLowerCase();\n case \"time\":\n return this.timeInputFormat.toLowerCase();\n default:\n return this.format.toLowerCase();\n }\n }\n\n /**\n */\n get inputFormatWithoutOffset(): string {\n if (this.hasDate && this.hasTime) {\n return `${this.dateInputFormat} ${this.timeInputFormat}`.trim();\n }\n\n if (this.hasDate) {\n return this.dateInputFormat;\n }\n\n if (this.hasTime) {\n return this.timeInputFormat;\n }\n\n return \"\";\n }\n\n /**\n */\n get inputFormat(): string {\n if (\n isIncludeTimeOffsetInDateTimes() &&\n this.dateInputFormat !== \"\" &&\n this.timeInputFormat !== \"\"\n ) {\n return `${this.inputFormatWithoutOffset} ${DATETIME_OFFSET_FORMAT}`;\n }\n return this.inputFormatWithoutOffset;\n }\n\n /**\n */\n get dateInputFormat(): string {\n if (!this.hasDate) {\n return \"\";\n }\n\n if (this._dateInputFormat) {\n return this._dateInputFormat;\n }\n\n // remove time and offset tokens\n const charsToRemove = \"HhaKmsSzXxO:\";\n\n let inputFormat = \"\";\n let isInQuotes = false;\n for (let i = 0; i < this.format.length; i++) {\n const char = this.format[i];\n if (char === \"'\") {\n isInQuotes = !isInQuotes;\n }\n if (isInQuotes || !charsToRemove.includes(char)) {\n inputFormat += char;\n }\n }\n\n this._dateInputFormat = inputFormat.trim();\n return this._dateInputFormat;\n }\n\n /**\n */\n get dateReadonlyFormat(): string {\n if (!this.hasDate) {\n return \"\";\n }\n\n return this.hasTime\n ? this.format.replace(this.timeInputFormat, \"\").trim()\n : this.format;\n }\n\n /**\n * return attribute placeholder or return formatlabel without time input format from contributions\n */\n get placeholder(): string {\n if (this._placeholder !== \"\") {\n return this._placeholder;\n }\n\n const formatLabel = this.getContribution(\"formatlabel\", \"\");\n\n if (this.hasDate && this.hasTime && formatLabel.includes(\" \")) {\n // return first part of formatlabel to keep placeholder matching date input\n return formatLabel.split(\" \")[0];\n }\n\n return formatLabel;\n }\n\n /**\n * Set placeholder text\n */\n set placeholder(placeholder: string) {\n this._placeholder = placeholder;\n }\n\n /**\n */\n get timeInputFormat(): string {\n if (!this.hasTime) {\n return \"\";\n }\n\n if (this._timeInputFormat) {\n return this._timeInputFormat;\n }\n\n const format = this.format;\n\n let timeFormatParts = [];\n if (format.includes(\"H\")) {\n timeFormatParts.push(\"HH\");\n } else if (format.includes(\"h\")) {\n timeFormatParts.push(\"hh\");\n }\n if (format.includes(\"m\")) {\n timeFormatParts.push(\"mm\");\n }\n if (format.includes(\"s\")) {\n timeFormatParts.push(\"ss\");\n }\n\n let timeFormat = timeFormatParts.join(\":\");\n if (format.includes(\"S\")) {\n timeFormat = `${timeFormat}.SSS`;\n }\n if (format.includes(\"a\")) {\n timeFormat = `${timeFormat} a`;\n }\n\n this._timeInputFormat = timeFormat;\n return this._timeInputFormat;\n }\n\n /**\n */\n get timeReadonlyFormat(): string {\n if (!this.hasTime) {\n return \"\";\n }\n\n return this.timeInputFormat;\n }\n\n /**\n */\n get dateInputValue(): string {\n return typeof this.value === \"string\" && this.dateInputFormat !== \"\"\n ? this.formatUtil.toFormat(this.value, this.dateInputFormat)\n : \"\";\n }\n\n /**\n */\n get timeInputValue(): string {\n return typeof this.value === \"string\" && this.timeInputFormat !== \"\"\n ? this.formatUtil.toFormat(this.value, this.timeInputFormat)\n : \"\";\n }\n\n /**\n * format value in readonly rendering\n */\n formatValue(value: ?string): string {\n if (value == null || value.toString() === \"\") {\n return \"\";\n }\n\n // when the value is exactly an iso date, render as date\n if (\n (this.type === \"datetime\" || this.type === \"timestamp\") &&\n DateUtil.hasFormat(value, ISO_DATE_FORMAT)\n ) {\n return DateUtil.toFormat(value, this.dateReadonlyFormat);\n }\n\n return this.formatUtil.toFormat(value, this.format);\n }\n\n /**\n * Retrieve readonly value, the date in the configurated format\n */\n get readonlyvalue(): string {\n if (typeof this.value === \"string\") {\n return this.formatValue(this.value.toString());\n }\n\n return \"\";\n }\n\n /**\n */\n get isAmbiguous(): boolean {\n if (typeof this.value === \"string\") {\n return this.formatUtil.isAmbiguous(this.value);\n }\n return false;\n }\n\n /**\n */\n get offset(): OffsetInfo | null {\n if (typeof this.value === \"string\") {\n return this.formatUtil.getOffset(this.value);\n }\n return null;\n }\n\n /**\n * Get minimum date\n */\n get mindate(): string | null {\n return this.getContribution(\"mindate\");\n }\n\n /**\n * Get maximum date\n */\n get maxdate(): string | null {\n return this.getContribution(\"maxdate\");\n }\n\n /**\n * Registers an error that was received from a server response\n */\n addServerError(error: FormErrorAnchor) {\n const { id, message, properties, layouthint } = error;\n if (properties && has(properties, \"format\") && this.formatLabel) {\n properties.format = this.formatLabel;\n }\n\n this._errorCollection.addServerError(id, message, properties, layouthint);\n }\n\n /**\n */\n getFormatConstraint(): IConstraintModel {\n switch (this.type) {\n case \"date\":\n return new DateTimeDateFormatConstraint(\n this.dateInputFormat,\n this.formatLabel,\n );\n case \"time\":\n return new DateTimeTimeFormatConstraint(\n this.timeInputFormat,\n this.formatLabel,\n );\n default:\n return new DatetimeFormatConstraint(\n this.type,\n this.inputFormat,\n this.formatLabel,\n );\n }\n }\n\n /**\n * Add Date constraints for attribute\n */\n addConstraints(): ConstraintCollection {\n const constraints = new ConstraintCollection();\n\n constraints.add(this.getFormatConstraint());\n\n if (this.mindate || this.maxdate) {\n constraints.add(\n new DateBoundaryConstraint(\n this.type,\n this.mindate,\n this.maxdate,\n this.inputFormat,\n ),\n );\n }\n\n return constraints;\n }\n\n /**\n */\n get readonlyWidth(): $Keys<typeof ATTRIBUTE_WIDTH> {\n if (this.type === \"date\" || this.type === \"time\") {\n return ATTRIBUTE_WIDTH.SMALL;\n }\n\n return ATTRIBUTE_WIDTH.MEDIUM;\n }\n\n /**\n */\n updateByAttribute(otherAttribute: AttributeType): void {\n this.reset();\n if (otherAttribute instanceof DatetimeAttributeModel) {\n const otherValue = otherAttribute.value;\n if (otherValue != null) {\n const inputValue = this.formatUtil.toFormat(\n otherValue,\n this.inputFormat,\n );\n this.update(inputValue);\n }\n } else {\n console.error(\n `update of datetime attribute with ${otherAttribute.type} not supported`,\n );\n }\n }\n}\n\nexport default DatetimeAttributeModel;\n"],"mappings":";;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,aAAA,GAAAD,OAAA;AAOA,IAAAE,qBAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,qBAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,6BAAA,GAAAF,sBAAA,CAAAH,OAAA;AACA,IAAAM,6BAAA,GAAAH,sBAAA,CAAAH,OAAA;AACA,IAAAO,yBAAA,GAAAJ,sBAAA,CAAAH,OAAA;AACA,IAAAQ,uBAAA,GAAAL,sBAAA,CAAAH,OAAA;AAEA,IAAAS,UAAA,GAAAT,OAAA;AAeA;AACA;AACA,MAAMU,sBAAsB,SAASC,6BAAoB,CAAC;EAIxD;AACF;EACEC,WAAWA,CACTC,SAAiB,EACjBC,sBAA8B,EAC9BC,YAA2B,EAC3B;IACA,KAAK,CAACF,SAAS,EAAEC,sBAAsB,EAAEC,YAAY,CAAC;IAAC,IAAAC,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAEvD,IAAI,CAACC,eAAe,CAAC,CAAC;EACxB;;EAEA;AACF;EACE,OAAOC,iBAAiBA,CAACC,aAAqB,EAAW;IAAA,IAAAC,QAAA;IACvD,OAAO,IAAAC,SAAA,CAAAL,OAAA,EAAAI,QAAA,IAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,CAAC,EAAAE,IAAA,CAAAF,QAAA,EAC9CD,aAAa,CAACI,IAChB,CA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AAA,GAEcP,sBAAsB","ignoreList":[]}
|
|
@@ -113,5 +113,22 @@ describe("dateAttributeModel", () => {
|
|
|
113
113
|
|
|
114
114
|
expect(attribute.placeholder).toBe("");
|
|
115
115
|
});
|
|
116
|
+
|
|
117
|
+
it("can update typical date attribute", () => {
|
|
118
|
+
const attribute = new DatetimeAttributeModel(
|
|
119
|
+
{},
|
|
120
|
+
{
|
|
121
|
+
type: "date",
|
|
122
|
+
label: "Date of birth",
|
|
123
|
+
mandatory: false,
|
|
124
|
+
formatlabel: "dd-mm-jjjj",
|
|
125
|
+
format: "dd-MM-yyyy",
|
|
126
|
+
},
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
attribute.update("13-12-1819");
|
|
130
|
+
|
|
131
|
+
expect(attribute.isValid).toBe(true);
|
|
132
|
+
});
|
|
116
133
|
});
|
|
117
134
|
});
|
|
@@ -303,4 +303,21 @@ describe("datetimeAttributeModel with offset on", () => {
|
|
|
303
303
|
value: "+02:00",
|
|
304
304
|
});
|
|
305
305
|
});
|
|
306
|
+
|
|
307
|
+
it("Date format with offset info", () => {
|
|
308
|
+
const attribute = new DatetimeAttributeModel(
|
|
309
|
+
{ key: "datetime", value: "1969-09-23T12:34:00+00:00" },
|
|
310
|
+
{
|
|
311
|
+
type: "datetime",
|
|
312
|
+
label: "Start date and time at company",
|
|
313
|
+
mandatory: false,
|
|
314
|
+
formatlabel: "dd-mm-yyyy hh:mm",
|
|
315
|
+
assistant: "The date and time of the first working day",
|
|
316
|
+
format: "dd-MM-yyyy HH:mm X",
|
|
317
|
+
},
|
|
318
|
+
);
|
|
319
|
+
|
|
320
|
+
expect(attribute.format).toBe("dd-MM-yyyy HH:mm X");
|
|
321
|
+
expect(attribute.errorCollection.isEmpty).toBe(true);
|
|
322
|
+
});
|
|
306
323
|
});
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.TimestampUtil = exports.TimeUtil = exports.DateUtil = exports.DateTimeUtil = void 0;
|
|
8
|
-
var _startsWith = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/starts-with"));
|
|
9
8
|
var _sort = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/sort"));
|
|
10
9
|
var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
|
|
11
10
|
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
|
@@ -23,9 +22,19 @@ var _Cookies = require("../browser/Cookies");
|
|
|
23
22
|
*/
|
|
24
23
|
class BaseDateTimeUtil {
|
|
25
24
|
constructor(isoFormat) {
|
|
25
|
+
let doOffsets = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
26
26
|
(0, _defineProperty2.default)(this, "_isoFormat", void 0);
|
|
27
|
+
(0, _defineProperty2.default)(this, "_doOffsets", void 0);
|
|
27
28
|
(0, _defineProperty2.default)(this, "_timeZone", typeof Intl === "undefined" ? "Etc/UTC" : Intl.DateTimeFormat().resolvedOptions().timeZone || "Etc/UTC");
|
|
28
29
|
this._isoFormat = isoFormat;
|
|
30
|
+
this._doOffsets = doOffsets;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Indicates if offsets and timezones are relevant
|
|
35
|
+
*/
|
|
36
|
+
get doOffsets() {
|
|
37
|
+
return this._doOffsets ? (0, _constants.isIncludeTimeOffsetInDateTimes)() : false;
|
|
29
38
|
}
|
|
30
39
|
|
|
31
40
|
/**
|
|
@@ -46,8 +55,7 @@ class BaseDateTimeUtil {
|
|
|
46
55
|
/**
|
|
47
56
|
*/
|
|
48
57
|
getIsoFormat() {
|
|
49
|
-
|
|
50
|
-
if ((0, _constants.isIncludeTimeOffsetInDateTimes)() && (0, _startsWith.default)(_context = this._isoFormat).call(_context, _constants.ISO_DATETIME_FORMAT)) {
|
|
58
|
+
if (this.doOffsets) {
|
|
51
59
|
return this._isoFormat + _constants.DATETIME_OFFSET_FORMAT;
|
|
52
60
|
}
|
|
53
61
|
return this._isoFormat;
|
|
@@ -56,7 +64,7 @@ class BaseDateTimeUtil {
|
|
|
56
64
|
/**
|
|
57
65
|
*/
|
|
58
66
|
convertFormat(javaFormat) {
|
|
59
|
-
var
|
|
67
|
+
var _context;
|
|
60
68
|
if (!javaFormat) {
|
|
61
69
|
return this.getIsoFormat();
|
|
62
70
|
}
|
|
@@ -70,7 +78,7 @@ class BaseDateTimeUtil {
|
|
|
70
78
|
let uts35Format = javaFormat;
|
|
71
79
|
|
|
72
80
|
// Sort keys by length (descending) to handle multi-character tokens first
|
|
73
|
-
const sortedKeys = (0, _sort.default)(
|
|
81
|
+
const sortedKeys = (0, _sort.default)(_context = (0, _keys.default)(javaToUTS35Map)).call(_context, (a, b) => b.length - a.length);
|
|
74
82
|
for (const javaToken of sortedKeys) {
|
|
75
83
|
const uts35Token = javaToUTS35Map[javaToken];
|
|
76
84
|
const regex = new RegExp(javaToken, "g"); // Match all occurrences
|
|
@@ -109,12 +117,12 @@ class BaseDateTimeUtil {
|
|
|
109
117
|
|
|
110
118
|
/**
|
|
111
119
|
*/
|
|
112
|
-
toFormat(
|
|
120
|
+
toFormat(date, targetFormat) {
|
|
113
121
|
let inputFormat = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.getIsoFormat();
|
|
114
122
|
const {
|
|
115
123
|
weekStartsOn
|
|
116
124
|
} = this.getOptions();
|
|
117
|
-
const parsedDate = this.toDate(
|
|
125
|
+
const parsedDate = this.toDate(date, inputFormat);
|
|
118
126
|
if ((0, _dateFns.isValid)(parsedDate)) {
|
|
119
127
|
return (0, _dateFns.format)(parsedDate, targetFormat, {
|
|
120
128
|
in: this.getDateFnsContext(),
|
|
@@ -143,11 +151,12 @@ class BaseDateTimeUtil {
|
|
|
143
151
|
/**
|
|
144
152
|
*/
|
|
145
153
|
hasFormat(date, sourceFormat) {
|
|
146
|
-
const
|
|
154
|
+
const parsedDate = this.toDate(date, sourceFormat);
|
|
155
|
+
const formattedValue = this.toFormat(parsedDate, sourceFormat);
|
|
147
156
|
if (formattedValue === "Invalid Date") {
|
|
148
157
|
return false;
|
|
149
158
|
}
|
|
150
|
-
const isOutsideRange = (0, _dateFns.isBefore)(
|
|
159
|
+
const isOutsideRange = (0, _dateFns.isBefore)(parsedDate, new Date(1000, 1, 1)) || (0, _dateFns.isAfter)(parsedDate, new Date(9999, 11, 31));
|
|
151
160
|
if (isOutsideRange) {
|
|
152
161
|
return false;
|
|
153
162
|
}
|
|
@@ -535,10 +544,10 @@ class BaseDateTimeUtil {
|
|
|
535
544
|
/**
|
|
536
545
|
*/
|
|
537
546
|
getDateFnsContext() {
|
|
538
|
-
if (_constants.IS_GRAALJS) {
|
|
539
|
-
return
|
|
547
|
+
if (this.doOffsets && !_constants.IS_GRAALJS) {
|
|
548
|
+
return (0, _tz.tz)(this.getTimeZone());
|
|
540
549
|
}
|
|
541
|
-
return
|
|
550
|
+
return undefined;
|
|
542
551
|
}
|
|
543
552
|
|
|
544
553
|
//////////// Offsets
|
|
@@ -564,12 +573,12 @@ class BaseDateTimeUtil {
|
|
|
564
573
|
*/
|
|
565
574
|
getTimezoneOffsets() {
|
|
566
575
|
const createOffsetObject = info => {
|
|
567
|
-
var
|
|
576
|
+
var _context2, _context3;
|
|
568
577
|
const sign = info.offset < 0 ? "-" : "+";
|
|
569
578
|
const absOffset = Math.abs(info.offset);
|
|
570
579
|
const hours = (0, _trunc.default)(absOffset);
|
|
571
580
|
const minutes = Math.round(absOffset % 1 * 60);
|
|
572
|
-
const offsetString = `${sign}${(0, _padStart.default)(
|
|
581
|
+
const offsetString = `${sign}${(0, _padStart.default)(_context2 = String(hours + (minutes === 60 ? 1 : 0))).call(_context2, 2, "0")}:${(0, _padStart.default)(_context3 = String(minutes % 60)).call(_context3, 2, "0")}`;
|
|
573
582
|
return {
|
|
574
583
|
label: info.name,
|
|
575
584
|
abbr: info.abbr,
|
|
@@ -610,7 +619,7 @@ const DateUtil = exports.DateUtil = new BaseDateTimeUtil(_constants.ISO_DATE_FOR
|
|
|
610
619
|
/**
|
|
611
620
|
* DateTimeUtil
|
|
612
621
|
*/
|
|
613
|
-
const DateTimeUtil = exports.DateTimeUtil = new BaseDateTimeUtil(_constants.ISO_DATETIME_FORMAT);
|
|
622
|
+
const DateTimeUtil = exports.DateTimeUtil = new BaseDateTimeUtil(_constants.ISO_DATETIME_FORMAT, true);
|
|
614
623
|
|
|
615
624
|
/**
|
|
616
625
|
* TimeUtil
|
|
@@ -620,5 +629,5 @@ const TimeUtil = exports.TimeUtil = new BaseDateTimeUtil(_constants.ISO_TIME_FOR
|
|
|
620
629
|
/**
|
|
621
630
|
* TimestampUtil
|
|
622
631
|
*/
|
|
623
|
-
const TimestampUtil = exports.TimestampUtil = new BaseDateTimeUtil(_constants.ISO_TIMESTAMP_FORMAT);
|
|
632
|
+
const TimestampUtil = exports.TimestampUtil = new BaseDateTimeUtil(_constants.ISO_TIMESTAMP_FORMAT, true);
|
|
624
633
|
//# sourceMappingURL=DateTimeUtil.js.map
|
|
@@ -54,13 +54,23 @@ export type OffsetInfo = {
|
|
|
54
54
|
*/
|
|
55
55
|
class BaseDateTimeUtil {
|
|
56
56
|
_isoFormat: string;
|
|
57
|
+
_doOffsets: boolean;
|
|
58
|
+
|
|
57
59
|
_timeZone: string =
|
|
58
60
|
typeof Intl === "undefined"
|
|
59
61
|
? "Etc/UTC"
|
|
60
62
|
: Intl.DateTimeFormat().resolvedOptions().timeZone || "Etc/UTC";
|
|
61
63
|
|
|
62
|
-
constructor(isoFormat: string) {
|
|
64
|
+
constructor(isoFormat: string, doOffsets: boolean = false) {
|
|
63
65
|
this._isoFormat = isoFormat;
|
|
66
|
+
this._doOffsets = doOffsets;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Indicates if offsets and timezones are relevant
|
|
71
|
+
*/
|
|
72
|
+
get doOffsets(): boolean {
|
|
73
|
+
return this._doOffsets ? isIncludeTimeOffsetInDateTimes() : false;
|
|
64
74
|
}
|
|
65
75
|
|
|
66
76
|
/**
|
|
@@ -88,10 +98,7 @@ class BaseDateTimeUtil {
|
|
|
88
98
|
/**
|
|
89
99
|
*/
|
|
90
100
|
getIsoFormat(): string {
|
|
91
|
-
if (
|
|
92
|
-
isIncludeTimeOffsetInDateTimes() &&
|
|
93
|
-
this._isoFormat.startsWith(ISO_DATETIME_FORMAT)
|
|
94
|
-
) {
|
|
101
|
+
if (this.doOffsets) {
|
|
95
102
|
return this._isoFormat + DATETIME_OFFSET_FORMAT;
|
|
96
103
|
}
|
|
97
104
|
return this._isoFormat;
|
|
@@ -158,13 +165,13 @@ class BaseDateTimeUtil {
|
|
|
158
165
|
/**
|
|
159
166
|
*/
|
|
160
167
|
toFormat(
|
|
161
|
-
|
|
168
|
+
date: string | Date,
|
|
162
169
|
targetFormat: string,
|
|
163
170
|
inputFormat: string = this.getIsoFormat(),
|
|
164
171
|
): string {
|
|
165
172
|
const { weekStartsOn } = this.getOptions();
|
|
166
173
|
|
|
167
|
-
const parsedDate = this.toDate(
|
|
174
|
+
const parsedDate = this.toDate(date, inputFormat);
|
|
168
175
|
|
|
169
176
|
if (isValid(parsedDate)) {
|
|
170
177
|
return format(parsedDate, targetFormat, {
|
|
@@ -197,14 +204,16 @@ class BaseDateTimeUtil {
|
|
|
197
204
|
/**
|
|
198
205
|
*/
|
|
199
206
|
hasFormat(date: string, sourceFormat: string): boolean {
|
|
200
|
-
const
|
|
207
|
+
const parsedDate = this.toDate(date, sourceFormat);
|
|
208
|
+
|
|
209
|
+
const formattedValue = this.toFormat(parsedDate, sourceFormat);
|
|
201
210
|
if (formattedValue === "Invalid Date") {
|
|
202
211
|
return false;
|
|
203
212
|
}
|
|
204
213
|
|
|
205
214
|
const isOutsideRange =
|
|
206
|
-
isBefore(
|
|
207
|
-
isAfter(
|
|
215
|
+
isBefore(parsedDate, new Date(1000, 1, 1)) ||
|
|
216
|
+
isAfter(parsedDate, new Date(9999, 11, 31));
|
|
208
217
|
if (isOutsideRange) {
|
|
209
218
|
return false;
|
|
210
219
|
}
|
|
@@ -740,10 +749,10 @@ class BaseDateTimeUtil {
|
|
|
740
749
|
/**
|
|
741
750
|
*/
|
|
742
751
|
getDateFnsContext(): null | Function {
|
|
743
|
-
if (IS_GRAALJS) {
|
|
744
|
-
return
|
|
752
|
+
if (this.doOffsets && !IS_GRAALJS) {
|
|
753
|
+
return tz(this.getTimeZone());
|
|
745
754
|
}
|
|
746
|
-
return
|
|
755
|
+
return undefined;
|
|
747
756
|
}
|
|
748
757
|
|
|
749
758
|
//////////// Offsets
|
|
@@ -829,6 +838,7 @@ const DateUtil: BaseDateTimeUtil = new BaseDateTimeUtil(ISO_DATE_FORMAT);
|
|
|
829
838
|
*/
|
|
830
839
|
const DateTimeUtil: BaseDateTimeUtil = new BaseDateTimeUtil(
|
|
831
840
|
ISO_DATETIME_FORMAT,
|
|
841
|
+
true,
|
|
832
842
|
);
|
|
833
843
|
|
|
834
844
|
/**
|
|
@@ -841,6 +851,7 @@ const TimeUtil: BaseDateTimeUtil = new BaseDateTimeUtil(ISO_TIME_FORMAT);
|
|
|
841
851
|
*/
|
|
842
852
|
const TimestampUtil: BaseDateTimeUtil = new BaseDateTimeUtil(
|
|
843
853
|
ISO_TIMESTAMP_FORMAT,
|
|
854
|
+
true,
|
|
844
855
|
);
|
|
845
856
|
|
|
846
857
|
export { DateUtil, DateTimeUtil, TimeUtil, TimestampUtil };
|