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
diff --git a/src/views/Configuration/DateTimeSettings/DateTimeSettings.vue b/src/views/Configuration/DateTimeSettings/DateTimeSettings.vue
index 2e3fc19..f1b6475 100644
--- a/src/views/Configuration/DateTimeSettings/DateTimeSettings.vue
+++ b/src/views/Configuration/DateTimeSettings/DateTimeSettings.vue
@@ -317,10 +317,20 @@
       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 @@
           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);
     }
   }
 };