MCPcopy Index your code
hub / github.com/UI5/webcomponents / ToDateTime

Class ToDateTime

packages/main/src/dynamic-date-range-options/ToDateTime.ts:23–182  ·  view source on GitHub ↗

* @class * @implements {IDynamicDateRangeOption} * @constructor * @public * @since 2.11.0

Source from the content-addressed store, hash-verified

21 */
22
23class ToDateTime implements IDynamicDateRangeOption {
24 template: JsxTemplate;
25 private _showTimeView: boolean;
26 private _currentDateValue: Date;
27
28 constructor() {
29 this.template = FromDateTimeTemplate;
30 this._showTimeView = false;
31 this._currentDateValue = UI5Date.getInstance();
32 }
33
34 parse(value: string): DynamicDateRangeValue {
35 const dateText = value.replace(this.toText, "").trim();
36 const date = this.getFormat().parse(dateText) as Date;
37 const returnValue = { operator: "", values: [] } as DynamicDateRangeValue;
38
39 returnValue.operator = this.operator;
40 returnValue.values = [date];
41
42 return returnValue;
43 }
44
45 format(value: DynamicDateRangeValue): string {
46 const valuesArray = value?.values as Array<Date>;
47
48 if (!valuesArray || valuesArray.length === 0) {
49 return "";
50 }
51
52 const formattedValue = this.getFormat().format(valuesArray[0]);
53
54 return `${this.toText} ${formattedValue}`;
55 }
56
57 toDates(value: DynamicDateRangeValue): Array<Date> {
58 return dateTimeOptionToDates(value);
59 }
60
61 resetState?: (() => void) | undefined = () => {
62 this._showTimeView = false;
63 }
64
65 get text(): string {
66 return DynamicDateRange.i18nBundle.getText(DYNAMIC_DATE_RANGE_TO_TEXT);
67 }
68
69 get operator() {
70 return "TODATETIME";
71 }
72
73 get icon() {
74 return "appointment-2";
75 }
76
77 get showDateView() {
78 return !this._showTimeView;
79 }
80

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected