fix date issue +1 time zone in date widget (#4982)

This commit is contained in:
Eugenio Romano 2019-08-08 22:52:22 +01:00 committed by GitHub
parent cb988b0145
commit 4aa0f49c58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -398,7 +398,7 @@ export class FormFieldModel extends FormWidgetModel {
}
break;
case FormFieldTypes.DATETIME:
const dateTimeValue = moment(this.value, this.dateDisplayFormat, true);
const dateTimeValue = moment(this.value, this.dateDisplayFormat, true).utc();
if (dateTimeValue && dateTimeValue.isValid()) {
/* cspell:disable-next-line */
this.form.values[this.id] = dateTimeValue.format('YYYY-MM-DDTHH:mm:ssZ');

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
/* tslint:disable:component-selector */
/* tslint:disable:component-selector */
import { Component, OnInit, ViewEncapsulation, OnDestroy } from '@angular/core';
import { DateAdapter, MAT_DATE_FORMATS } from '@angular/material';
@ -75,7 +75,10 @@ export class DateTimeWidgetComponent extends WidgetComponent implements OnInit,
this.maxDate = moment(this.field.maxValue, 'YYYY-MM-DDTHH:mm:ssZ');
}
}
this.displayDate = moment(this.field.value, this.field.dateDisplayFormat);
this.displayDate = moment(this.field.value, this.field.dateDisplayFormat)
.add(
moment(this.field.value, this.field.dateDisplayFormat).utcOffset(),
'minutes');
}
ngOnDestroy() {