diff options
author | Sukanya Pandey <sukapan1@in.ibm.com> | 2020-07-30 19:26:03 +0300 |
---|---|---|
committer | Yoshie Muranaka <yoshiemuranaka@gmail.com> | 2020-08-04 21:03:44 +0300 |
commit | b5c161b4b098e5f303cb81cd782c5abe88722456 (patch) | |
tree | d8acdeb7b1985dcc5cb4a64f72934317ed9de4d0 /src/views/Configuration | |
parent | b15a0ea32bc1fd434c370876ec58b0fc263c814c (diff) | |
download | webui-vue-b5c161b4b098e5f303cb81cd782c5abe88722456.tar.xz |
Remove time bug from date and time settings page
-Bug is while setting the UTC time, UTC time is getting saved
with offset as per the timezone.
-After this commit the UTC time will be saved as UTC time with no offset.
Signed-off-by: Sukanya Pandey <sukapan1@in.ibm.com>
Change-Id: I4731cb1f8e3daae3801059e1653d059c51c26f7d
Diffstat (limited to 'src/views/Configuration')
-rw-r--r-- | src/views/Configuration/DateTimeSettings/DateTimeSettings.vue | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/src/views/Configuration/DateTimeSettings/DateTimeSettings.vue b/src/views/Configuration/DateTimeSettings/DateTimeSettings.vue index 2e3fc195..f1b64751 100644 --- a/src/views/Configuration/DateTimeSettings/DateTimeSettings.vue +++ b/src/views/Configuration/DateTimeSettings/DateTimeSettings.vue @@ -317,10 +317,20 @@ export default { let isNTPEnabled = this.form.configurationSelected === 'ntp'; if (!isNTPEnabled) { + const isUtcDisplay = this.$store.getters['global/isUtcDisplay']; + let date; + dateTimeForm.ntpProtocolEnabled = false; - dateTimeForm.updatedDateTime = new Date( - `${this.form.manual.date} ${this.form.manual.time}` - ).toISOString(); + + if (isUtcDisplay) { + // Create UTC Date + date = this.getUtcDate(this.form.manual.date, this.form.manual.time); + } else { + // Create local Date + date = new Date(`${this.form.manual.date} ${this.form.manual.time}`); + } + + dateTimeForm.updatedDateTime = date.toISOString(); } else { ntpFirstAddress = this.form.ntp.firstAddress; ntpSecondAddress = this.form.ntp.secondAddress; @@ -353,6 +363,20 @@ export default { this.$v.form.$reset(); this.endLoader(); }); + }, + getUtcDate(date, time) { + // Split user input string values to create + // a UTC Date object + const datesArray = date.split('-'); + const timeArray = time.split(':'); + let utcDate = Date.UTC( + datesArray[0], // User input year + datesArray[1], // User input month + datesArray[2], // User input day + timeArray[0], // User input hour + timeArray[1] // User input minute + ); + return new Date(utcDate); } } }; |