diff --git a/src/addons/calendar/pages/edit-event/edit-event.html b/src/addons/calendar/pages/edit-event/edit-event.html index 912194c76..c5b628d9d 100644 --- a/src/addons/calendar/pages/edit-event/edit-event.html +++ b/src/addons/calendar/pages/edit-event/edit-event.html @@ -31,7 +31,7 @@

{{ 'core.date' | translate }}

+ [max]="maxDate" [min]="minDate"> @@ -156,7 +156,7 @@ + [placeholder]="'addon.calendar.durationuntil' | translate" [displayFormat]="dateFormat"> diff --git a/src/addons/calendar/pages/edit-event/edit-event.page.ts b/src/addons/calendar/pages/edit-event/edit-event.page.ts index 79190818a..f5a21a733 100644 --- a/src/addons/calendar/pages/edit-event/edit-event.page.ts +++ b/src/addons/calendar/pages/edit-event/edit-event.page.ts @@ -45,6 +45,7 @@ import { CanLeave } from '@guards/can-leave'; import { CoreForms } from '@singletons/form'; import { CoreReminders, CoreRemindersService, CoreRemindersUnits } from '@features/reminders/services/reminders'; import { CoreRemindersSetReminderMenuComponent } from '@features/reminders/components/set-reminder-menu/set-reminder-menu'; +import moment from 'moment-timezone'; /** * Page that displays a form to create/edit an event. @@ -454,8 +455,8 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy, CanLeave { async submit(): Promise { // Validate data. const formData = this.form.value; - const timeStartDate = CoreTimeUtils.convertToTimestamp(formData.timestart, true); - const timeUntilDate = CoreTimeUtils.convertToTimestamp(formData.timedurationuntil, true); + const timeStartDate = moment(formData.timestart).unix(); + const timeUntilDate = moment(formData.timedurationuntil).unix(); const timeDurationMinutes = parseInt(formData.timedurationminutes || '', 10); let error: string | undefined; diff --git a/src/addons/mod/data/fields/date/component/addon-mod-data-field-date.html b/src/addons/mod/data/fields/date/component/addon-mod-data-field-date.html index d0acc0ca8..f6bcd38db 100644 --- a/src/addons/mod/data/fields/date/component/addon-mod-data-field-date.html +++ b/src/addons/mod/data/fields/date/component/addon-mod-data-field-date.html @@ -1,7 +1,7 @@ + [disabled]="searchMode && !searchFields!['f_'+field.id+'_z']" [displayFormat]="format"> diff --git a/src/addons/userprofilefield/datetime/services/handlers/datetime.ts b/src/addons/userprofilefield/datetime/services/handlers/datetime.ts index 413ad1ccd..96f3deaba 100644 --- a/src/addons/userprofilefield/datetime/services/handlers/datetime.ts +++ b/src/addons/userprofilefield/datetime/services/handlers/datetime.ts @@ -18,9 +18,9 @@ import { AuthEmailSignupProfileField } from '@features/login/services/login-help import { CoreUserProfileField } from '@features/user/services/user'; import { CoreUserProfileFieldHandler, CoreUserProfileFieldHandlerData } from '@features/user/services/user-profile-field-delegate'; import { CoreFormFields } from '@singletons/form'; -import { CoreTimeUtils } from '@services/utils/time'; import { makeSingleton } from '@singletons'; import { AddonUserProfileFieldDatetimeComponent } from '../../component/datetime'; +import moment from 'moment-timezone'; /** * Datetime user profile field handlers. @@ -61,7 +61,7 @@ export class AddonUserProfileFieldDatetimeHandlerService implements CoreUserProf return { type: 'datetime', name: 'profile_field_' + field.shortname, - value: CoreTimeUtils.convertToTimestamp( formValues[name]), + value: moment( formValues[name]).unix(), }; } } diff --git a/src/core/services/utils/time.ts b/src/core/services/utils/time.ts index fd44ad144..b22b5b44b 100644 --- a/src/core/services/utils/time.ts +++ b/src/core/services/utils/time.ts @@ -261,23 +261,14 @@ export class CoreTimeUtilsProvider { /** * 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 applyOffset Whether to apply offset to date or not. * @return Converted timestamp. + * @deprecated since 4.1. Use moment(date).unix() instead. */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars convertToTimestamp(date: string, applyOffset?: boolean): number { - const timestamp = moment(date).unix(); - - if (applyOffset !== undefined) { - return applyOffset ? timestamp - moment().utcOffset() * 60 : timestamp; - } - - return typeof date == 'string' && date.slice(-1) == 'Z' - ? timestamp - moment().utcOffset() * 60 - : timestamp; + return moment(date).unix(); } /**