Closed
Description
Preconditions (*)
- Magento 2.3.1
Steps to reproduce (*)
- Define a ui_component form.xml
- add a Datetime UI component with the option 'timeOnly' set to 'yes'
<field name="start_time"]
[argument name="data" xsi:type="array"]
[item name="config" xsi:type="array"]
[item name="dataType" xsi:type="string"]string[/item]
[item name="label" xsi:type="string" translate="true"]Start Time[/item]
[item name="formElement" xsi:type="string"]date[/item]
[item name="source" xsi:type="string"]import_profile[/item]
[item name="dataScope" xsi:type="string"]start_time[/item]
[item name="options" xsi:type="array"]
[item name="timeOnlyTitle" xsi:type="string"]Select Start Time[/item]
[item name="showsTime" xsi:type="boolean"]true[/item]
[item name="timeOnly" xsi:type="boolean"]true[/item]
[item name="timeFormat" xsi:type="string"]HH:mm:ss[/item]
[item name="dateFormat" xsi:type="string"]yyyy-MM-dd[/item]
[/item]
[/item]
[/argument]
[/field>
{code}
1. Save the form and check the result.
### Expected result (*)
1. Correct time value
### Actual result (*)
1. The value states: 'Invalid Date'
### Additional information
This problem doesn't occur when the option 'timeOnly' is not defined.
My best guess is that the problem happens inside the /module-ui/view/base/web/js/form/element/date.js at 'onShiftedValueChange' function..
{code}
/**
* Prepares and sets date/time value that will be sent
* to the server.
* * @param {String} shiftedValue
*/
onShiftedValueChange: function (shiftedValue) {
var value,
formattedValue,
momentValue;
if (shiftedValue) {
momentValue = moment(shiftedValue, this.pickerDateTimeFormat);
if (this.options.showsTime) {
formattedValue = moment(momentValue).format(this.timezoneFormat);
//formattedValue returns an incorrect value.
value = moment.tz(formattedValue, this.storeTimeZone).tz('UTC').toISOString();
} else {
value = momentValue.format(this.outputDateFormat);
}
} else {
value = '';
}
if (value !== this.value()) {
this.value(value);
}
},
Metadata
Metadata
Assignees
Labels
Gate 3 Passed. Manual verification of the issue completed. Issue is confirmedA defect with this priority could have functionality issues which are not to expectations.The issue has been reproduced on latest 2.2 releaseThe issue has been reproduced on latest 2.3 releaseMajor restrictions or short-term circumventions are required until a fix is available.Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
Type
Projects
Status
Done