diff --git a/src/addon/calendar/pages/edit-event/edit-event.ts b/src/addon/calendar/pages/edit-event/edit-event.ts index 2daaf90cf..99b887ac8 100644 --- a/src/addon/calendar/pages/edit-event/edit-event.ts +++ b/src/addon/calendar/pages/edit-event/edit-event.ts @@ -423,8 +423,8 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy { submit(): void { // Validate data. const formData = this.eventForm.value, - timeStartDate = new Date(formData.timestart), - timeUntilDate = this.timeUtils.datetimeToDate(formData.timedurationuntil), + timeStartDate = this.timeUtils.convertToTimestamp(formData.timestart), + timeUntilDate = this.timeUtils.convertToTimestamp(formData.timedurationuntil), timeDurationMinutes = parseInt(formData.timedurationminutes || '', 10); let error; @@ -436,7 +436,7 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy { error = 'core.selectagroup'; } else if (formData.eventtype == AddonCalendarProvider.TYPE_CATEGORY && !formData.categoryid) { error = 'core.selectacategory'; - } else if (formData.duration == 1 && timeStartDate.getTime() > timeUntilDate.getTime()) { + } else if (formData.duration == 1 && timeStartDate > timeUntilDate) { error = 'addon.calendar.invalidtimedurationuntil'; } else if (formData.duration == 2 && (isNaN(timeDurationMinutes) || timeDurationMinutes < 1)) { error = 'addon.calendar.invalidtimedurationminutes'; @@ -453,7 +453,7 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy { const data: any = { name: formData.name, eventtype: formData.eventtype, - timestart: Math.floor(timeStartDate.getTime() / 1000), + timestart: timeStartDate, description: { text: formData.description, format: 1 @@ -473,7 +473,7 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy { } if (formData.duration == 1) { - data.timedurationuntil = Math.floor(timeUntilDate.getTime() / 1000); + data.timedurationuntil = timeUntilDate; } else if (formData.duration == 2) { data.timedurationminutes = formData.timedurationminutes; } diff --git a/src/addon/userprofilefield/datetime/providers/handler.ts b/src/addon/userprofilefield/datetime/providers/handler.ts index 65a7a6f66..29d3d321e 100644 --- a/src/addon/userprofilefield/datetime/providers/handler.ts +++ b/src/addon/userprofilefield/datetime/providers/handler.ts @@ -14,6 +14,7 @@ // limitations under the License. import { Injectable, Injector } from '@angular/core'; import { CoreUserProfileFieldHandler, CoreUserProfileFieldHandlerData } from '@core/user/providers/user-profile-field-delegate'; +import { CoreTimeUtilsProvider } from '@providers/utils/time'; import { AddonUserProfileFieldDatetimeComponent } from '../component/datetime'; /** @@ -24,7 +25,7 @@ export class AddonUserProfileFieldDatetimeHandler implements CoreUserProfileFiel name = 'AddonUserProfileFieldDatetime'; type = 'datetime'; - constructor() { + constructor(protected timeUtils: CoreTimeUtilsProvider) { // Nothing to do. } @@ -50,12 +51,10 @@ export class AddonUserProfileFieldDatetimeHandler implements CoreUserProfileFiel const name = 'profile_field_' + field.shortname; if (formValues[name]) { - const milliseconds = new Date(formValues[name]).getTime(); - return { type: 'datetime', name: 'profile_field_' + field.shortname, - value: Math.round(milliseconds / 1000) + value: this.timeUtils.convertToTimestamp(formValues[name]) }; } } diff --git a/src/components/ion-tabs/ion-tabs.scss b/src/components/ion-tabs/ion-tabs.scss index 6b16d9401..31f667650 100644 --- a/src/components/ion-tabs/ion-tabs.scss +++ b/src/components/ion-tabs/ion-tabs.scss @@ -3,7 +3,6 @@ $core-sidetab-size: 60px !default; ion-app.app-root core-ion-tabs { .tabbar { z-index: 101; // For some reason, the regular z-index isn't enough with our tabs, use a higher one. - height: 56px; .core-ion-tabs-loading { height: 100%; diff --git a/src/providers/utils/time.ts b/src/providers/utils/time.ts index 6e2e00aa7..9be16dd58 100644 --- a/src/providers/utils/time.ts +++ b/src/providers/utils/time.ts @@ -308,22 +308,7 @@ export class CoreTimeUtilsProvider { toDatetimeFormat(timestamp?: number): string { timestamp = timestamp || Date.now(); - return this.userDate(timestamp, 'YYYY-MM-DDTHH:mm:ss.SSS', false); - } - - /** - * Convert the value of a ion-datetime to a Date. - * - * @param {string} value Value of ion-datetime. - * @return {Date} Date. - */ - datetimeToDate(value: string): Date { - if (typeof value == 'string' && value.slice(-1) == 'Z') { - // The value shoudln't have the timezone because it causes problems, remove it. - value = value.substr(0, value.length - 1); - } - - return new Date(value); + return this.userDate(timestamp, 'YYYY-MM-DDTHH:mm:ss.SSS', false) + 'Z'; } /** @@ -333,7 +318,11 @@ export class CoreTimeUtilsProvider { * @return {number} Converted timestamp. */ convertToTimestamp(date: string): number { - return moment(date).unix() - (moment().utcOffset() * 60); + if (typeof date == 'string' && date.slice(-1) == 'Z') { + return moment(date).unix() - (moment().utcOffset() * 60); + } + + return moment(date).unix(); } /**