summaryrefslogtreecommitdiff
path: root/src/views/Configuration/DateTimeSettings
diff options
context:
space:
mode:
authorSukanya Pandey <sukapan1@in.ibm.com>2020-07-30 19:26:03 +0300
committerYoshie Muranaka <yoshiemuranaka@gmail.com>2020-08-04 21:03:44 +0300
commitb5c161b4b098e5f303cb81cd782c5abe88722456 (patch)
treed8acdeb7b1985dcc5cb4a64f72934317ed9de4d0 /src/views/Configuration/DateTimeSettings
parentb15a0ea32bc1fd434c370876ec58b0fc263c814c (diff)
downloadwebui-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/DateTimeSettings')
-rw-r--r--src/views/Configuration/DateTimeSettings/DateTimeSettings.vue30
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);
}
}
};