@beinformed/ui 1.59.4 → 1.59.6

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.
@@ -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","_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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O,CAAC1B,KAAK,CACX,qCAAqCqB,cAAc,CAACnG,IAAI,gBAC1D,CAAC;IACH;EACF;AACF;AAAC,IAAAyG,QAAA,GAAAC,OAAA,CAAAjH,OAAA,GAEcP,sBAAsB","ignoreList":[]}
1
+ {"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","dateEraChars","timeOffsetChars","isInQuotes","isInDate","i","char","prevChar","nextChar","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 const dateEraChars = \"yMLdQDEewGu\";\n const timeOffsetChars = \"HhaKmsSZzXxO\";\n\n const format = this.format;\n let inputFormat = \"\";\n\n let isInQuotes = false;\n let isInDate = false;\n\n for (let i = 0; i < format.length; i++) {\n const char = format[i];\n if (char === \"'\") {\n const prevChar = i > 0 ? format[i - 1] : \"\";\n const nextChar = format[i + 1];\n isInQuotes = prevChar === \"'\" || nextChar === \"'\" ? true : !isInQuotes;\n } else if (!isInQuotes && dateEraChars.includes(char)) {\n isInDate = true;\n } else if (!isInQuotes && timeOffsetChars.includes(char)) {\n isInDate = false;\n }\n\n if (isInDate) {\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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,OAAO,EAAE;MAChCc,WAAW,CAACE,GAAG,CACb,IAAIC,+BAAsB,CACxB,IAAI,CAACjG,IAAI,EACT,IAAI,CAAC+E,OAAO,EACZ,IAAI,CAACC,OAAO,EACZ,IAAI,CAAC5C,WACP,CACF,CAAC;IACH;IAEA,OAAO0D,WAAW;EACpB;;EAEA;AACF;EACE,IAAII,aAAaA,CAAA,EAAkC;IACjD,IAAI,IAAI,CAAClG,IAAI,KAAK,MAAM,IAAI,IAAI,CAACA,IAAI,KAAK,MAAM,EAAE;MAChD,OAAOmG,0BAAe,CAACC,KAAK;IAC9B;IAEA,OAAOD,0BAAe,CAACE,MAAM;EAC/B;;EAEA;AACF;EACEC,iBAAiBA,CAACC,cAA6B,EAAQ;IACrD,IAAI,CAACC,KAAK,CAAC,CAAC;IACZ,IAAID,cAAc,YAAYrH,sBAAsB,EAAE;MACpD,MAAMuH,UAAU,GAAGF,cAAc,CAAChG,KAAK;MACvC,IAAIkG,UAAU,IAAI,IAAI,EAAE;QACtB,MAAMC,UAAU,GAAG,IAAI,CAACzG,UAAU,CAACS,QAAQ,CACzC+F,UAAU,EACV,IAAI,CAACrE,WACP,CAAC;QACD,IAAI,CAACuE,MAAM,CAACD,UAAU,CAAC;MACzB;IACF,CAAC,MAAM;MACLE,OAAO,CAAC1B,KAAK,CACX,qCAAqCqB,cAAc,CAACvG,IAAI,gBAC1D,CAAC;IACH;EACF;AACF;AAAC,IAAA6G,QAAA,GAAAC,OAAA,CAAArH,OAAA,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
  });
@@ -304,20 +304,42 @@ describe("datetimeAttributeModel with offset on", () => {
304
304
  });
305
305
  });
306
306
 
307
- it("Date format with offset info", () => {
308
- const attribute = new DatetimeAttributeModel(
307
+ it("Date formats", () => {
308
+ const datetime = new DatetimeAttributeModel(
309
309
  { key: "datetime", value: "1969-09-23T12:34:00+00:00" },
310
310
  {
311
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
312
  format: "dd-MM-yyyy HH:mm X",
317
313
  },
318
314
  );
319
315
 
320
- expect(attribute.format).toBe("dd-MM-yyyy HH:mm X");
321
- expect(attribute.errorCollection.isEmpty).toBe(true);
316
+ expect(datetime.format).toBe("dd-MM-yyyy HH:mm X");
317
+ expect(datetime.dateInputFormat).toBe("dd-MM-yyyy");
318
+ expect(datetime.timeInputFormat).toBe("HH:mm");
319
+ expect(datetime.errorCollection.isEmpty).toBe(true);
320
+
321
+ const timestamp = new DatetimeAttributeModel(
322
+ { key: "timestamp", value: "1969-09-23T12:34:00.010+00:00" },
323
+ {
324
+ type: "timestamp",
325
+ format: "dd-MM-yyyy HH:mm:ss.SSS X",
326
+ },
327
+ );
328
+
329
+ expect(timestamp.format).toBe("dd-MM-yyyy HH:mm:ss.SSS X");
330
+ expect(timestamp.dateInputFormat).toBe("dd-MM-yyyy");
331
+ expect(timestamp.timeInputFormat).toBe("HH:mm:ss.SSS");
332
+
333
+ const special = new DatetimeAttributeModel(
334
+ { key: "timestamp", value: "1969-09-23T12:34:00.010+00:00" },
335
+ {
336
+ type: "timestamp",
337
+ format: "'special' do 'de' MMMM yyyy h 'o''clock'",
338
+ },
339
+ );
340
+
341
+ expect(special.format).toBe("'special' do 'de' MMMM yyyy h 'o''clock'");
342
+ expect(special.dateInputFormat).toBe("do 'de' MMMM yyyy");
343
+ // expect(special.timeInputFormat).toBe("HH:mm:ss.SSS");
322
344
  });
323
345
  });
@@ -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
- var _context;
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 _context2;
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)(_context2 = (0, _keys.default)(javaToUTS35Map)).call(_context2, (a, b) => b.length - a.length);
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(isoDate, targetFormat) {
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(isoDate, inputFormat);
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 formattedValue = this.toFormat(date, sourceFormat, sourceFormat);
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)(formattedValue, new Date(1000, 1, 1)) || (0, _dateFns.isAfter)(formattedValue, new Date(9999, 11, 31));
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 null; // tz method does not work in graal (yet)
547
+ if (this.doOffsets && !_constants.IS_GRAALJS) {
548
+ return (0, _tz.tz)(this.getTimeZone());
540
549
  }
541
- return (0, _tz.tz)(this.getTimeZone());
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 _context3, _context4;
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)(_context3 = String(hours + (minutes === 60 ? 1 : 0))).call(_context3, 2, "0")}:${(0, _padStart.default)(_context4 = String(minutes % 60)).call(_context4, 2, "0")}`;
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
- isoDate: string | Date,
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(isoDate, inputFormat);
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 formattedValue = this.toFormat(date, sourceFormat, sourceFormat);
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(formattedValue, new Date(1000, 1, 1)) ||
207
- isAfter(formattedValue, new Date(9999, 11, 31));
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 null; // tz method does not work in graal (yet)
752
+ if (this.doOffsets && !IS_GRAALJS) {
753
+ return tz(this.getTimeZone());
745
754
  }
746
- return tz(this.getTimeZone());
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 };