MOBILE-3320 calendar: Fix date pickers
parent
ce451e9a1d
commit
029e24e5cb
|
@ -450,8 +450,8 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy, CanLeave {
|
||||||
async submit(): Promise<void> {
|
async submit(): Promise<void> {
|
||||||
// Validate data.
|
// Validate data.
|
||||||
const formData = this.form.value;
|
const formData = this.form.value;
|
||||||
const timeStartDate = CoreTimeUtils.convertToTimestamp(formData.timestart);
|
const timeStartDate = CoreTimeUtils.convertToTimestamp(formData.timestart, true);
|
||||||
const timeUntilDate = CoreTimeUtils.convertToTimestamp(formData.timedurationuntil);
|
const timeUntilDate = CoreTimeUtils.convertToTimestamp(formData.timedurationuntil, true);
|
||||||
const timeDurationMinutes = parseInt(formData.timedurationminutes || '', 10);
|
const timeDurationMinutes = parseInt(formData.timedurationminutes || '', 10);
|
||||||
let error: string | undefined;
|
let error: string | undefined;
|
||||||
|
|
||||||
|
|
|
@ -328,15 +328,23 @@ export class CoreTimeUtilsProvider {
|
||||||
/**
|
/**
|
||||||
* Convert a text into user timezone timestamp.
|
* Convert a text into user timezone timestamp.
|
||||||
*
|
*
|
||||||
|
* @todo The `applyOffset` argument is only used as a workaround, it should be removed once
|
||||||
|
* MOBILE-3784 is resolved.
|
||||||
|
*
|
||||||
* @param date To convert to timestamp.
|
* @param date To convert to timestamp.
|
||||||
|
* @param applyOffset Whether to apply offset to date or not.
|
||||||
* @return Converted timestamp.
|
* @return Converted timestamp.
|
||||||
*/
|
*/
|
||||||
convertToTimestamp(date: string): number {
|
convertToTimestamp(date: string, applyOffset?: boolean): number {
|
||||||
if (typeof date == 'string' && date.slice(-1) == 'Z') {
|
const timestamp = moment(date).unix();
|
||||||
return moment(date).unix() - (moment().utcOffset() * 60);
|
|
||||||
|
if (typeof applyOffset !== 'undefined') {
|
||||||
|
return applyOffset ? timestamp - moment().utcOffset() * 60 : timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
return moment(date).unix();
|
return typeof date == 'string' && date.slice(-1) == 'Z'
|
||||||
|
? timestamp - moment().utcOffset() * 60
|
||||||
|
: timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue