@@ -55,11 +55,30 @@ class DateComponentBase extends UI5Element {
55
55
/**
56
56
* Determines the format, displayed in the input field.
57
57
* @default undefined
58
+ * @deprecated
58
59
* @public
59
60
*/
60
61
@property ( )
61
62
formatPattern ?: string ;
62
63
64
+ /**
65
+ * Determines the format, displayed in the input field.
66
+ * @default undefined
67
+ * @since 2.14.0
68
+ * @public
69
+ */
70
+ @property ( )
71
+ displayFormat ?: string ;
72
+
73
+ /**
74
+ * Determines the format, used for the value attribute.
75
+ * @default undefined
76
+ * @since 2.14.0
77
+ * @public
78
+ */
79
+ @property ( )
80
+ valueFormat ?: string ;
81
+
63
82
/**
64
83
* Determines the minimum date available for selection.
65
84
*
@@ -143,6 +162,14 @@ class DateComponentBase extends UI5Element {
143
162
return this . _formatPattern !== "medium" && this . _formatPattern !== "short" && this . _formatPattern !== "long" ;
144
163
}
145
164
165
+ get _isValueFormatPattern ( ) {
166
+ return this . _valueFormat !== "medium" && this . _valueFormat !== "short" && this . _valueFormat !== "long" ;
167
+ }
168
+
169
+ get _isDisplayFormatPattern ( ) {
170
+ return this . _displayFormat !== "medium" && this . _displayFormat !== "short" && this . _displayFormat !== "long" ;
171
+ }
172
+
146
173
get hasSecondaryCalendarType ( ) {
147
174
return ! ! this . secondaryCalendarType && this . secondaryCalendarType !== this . primaryCalendarType ;
148
175
}
@@ -159,7 +186,14 @@ class DateComponentBase extends UI5Element {
159
186
}
160
187
161
188
_getCalendarDateFromString ( value : string ) {
162
- const jsDate = this . getFormat ( ) . parse ( value ) as Date ;
189
+ const jsDate = this . getValueFormat ( ) . parse ( value ) as Date ;
190
+ if ( jsDate ) {
191
+ return CalendarDate . fromLocalJSDate ( jsDate , this . _primaryCalendarType ) ;
192
+ }
193
+ }
194
+
195
+ _getCalendarDateFromStringDisplayValue ( value : string ) {
196
+ const jsDate = this . getDisplayFormat ( ) . parse ( value ) as Date ;
163
197
if ( jsDate ) {
164
198
return CalendarDate . fromLocalJSDate ( jsDate , this . _primaryCalendarType ) ;
165
199
}
@@ -173,10 +207,32 @@ class DateComponentBase extends UI5Element {
173
207
}
174
208
175
209
_getStringFromTimestamp ( timestamp : number ) {
210
+ if ( ! timestamp ) {
211
+ return "" ;
212
+ }
213
+
176
214
const localDate = UI5Date . getInstance ( timestamp ) ;
177
215
return this . getFormat ( ) . format ( localDate , true ) ;
178
216
}
179
217
218
+ _getDisplayStringFromTimestamp ( timestamp : number ) {
219
+ if ( ! timestamp ) {
220
+ return "" ;
221
+ }
222
+
223
+ const localDate = UI5Date . getInstance ( timestamp ) ;
224
+ return this . getDisplayFormat ( ) . format ( localDate , true ) ;
225
+ }
226
+
227
+ _getValueStringFromTimestamp ( timestamp : number ) {
228
+ if ( ! timestamp ) {
229
+ return "" ;
230
+ }
231
+
232
+ const localDate = UI5Date . getInstance ( timestamp ) ;
233
+ return this . getValueFormat ( ) . format ( localDate , true ) ;
234
+ }
235
+
180
236
getFormat ( ) {
181
237
return this . _isPattern
182
238
? DateFormat . getDateInstance ( {
@@ -191,6 +247,58 @@ class DateComponentBase extends UI5Element {
191
247
} ) ;
192
248
}
193
249
250
+ get _displayFormat ( ) {
251
+ if ( this . displayFormat ) {
252
+ return this . displayFormat ;
253
+ }
254
+
255
+ return this . _formatPattern ;
256
+ }
257
+
258
+ get _valueFormat ( ) {
259
+ if ( this . valueFormat ) {
260
+ return this . valueFormat ;
261
+ }
262
+
263
+ if ( this . _formatPattern ) {
264
+ return this . _formatPattern ;
265
+ }
266
+
267
+ return "" ;
268
+ }
269
+
270
+ getDisplayFormat ( ) {
271
+ return this . _isDisplayFormatPattern
272
+ ? DateFormat . getDateInstance ( {
273
+ strictParsing : true ,
274
+ pattern : this . _displayFormat ,
275
+ calendarType : this . _primaryCalendarType ,
276
+ } )
277
+ : DateFormat . getDateInstance ( {
278
+ strictParsing : true ,
279
+ style : this . _displayFormat ,
280
+ calendarType : this . _primaryCalendarType ,
281
+ } ) ;
282
+ }
283
+
284
+ getValueFormat ( ) {
285
+ if ( ! this . _valueFormat ) {
286
+ return this . getISOFormat ( ) ;
287
+ }
288
+
289
+ return this . _isValueFormatPattern
290
+ ? DateFormat . getDateInstance ( {
291
+ strictParsing : true ,
292
+ pattern : this . _valueFormat ,
293
+ calendarType : this . _primaryCalendarType ,
294
+ } )
295
+ : DateFormat . getDateInstance ( {
296
+ strictParsing : true ,
297
+ style : this . _valueFormat ,
298
+ calendarType : this . _primaryCalendarType ,
299
+ } ) ;
300
+ }
301
+
194
302
getISOFormat ( ) {
195
303
if ( ! this . _isoFormatInstance ) {
196
304
this . _isoFormatInstance = DateFormat . getDateInstance ( {
0 commit comments