From d37acccee8b8768e9dc7f8adc90a3be4b21dba9d Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Thu, 13 Dec 2018 15:35:47 +0100 Subject: [PATCH] MOBILE-2754 core: Use Moodle strings for dates --- scripts/langindex.json | 15 +++ .../components/myoverview/myoverview.ts | 6 +- .../events/addon-block-timeline-events.html | 4 +- .../timeline/components/timeline/timeline.ts | 7 +- .../messages/pages/discussion/discussion.html | 4 +- src/addon/messages/providers/sync.ts | 5 +- .../mod/assign/components/index/index.ts | 5 +- .../addon-mod-assign-submission.html | 10 +- .../components/submission/submission.ts | 3 +- src/addon/mod/assign/providers/assign-sync.ts | 6 +- src/addon/mod/chat/components/index/index.ts | 3 +- src/addon/mod/chat/pages/chat/chat.html | 8 +- .../mod/choice/components/index/index.ts | 9 +- src/addon/mod/choice/providers/sync.ts | 7 +- .../action/addon-mod-data-action.html | 4 +- src/addon/mod/data/components/index/index.ts | 6 +- .../component/addon-mod-data-field-date.html | 2 +- src/addon/mod/data/providers/sync.ts | 7 +- .../mod/feedback/components/index/index.ts | 10 +- .../mod/feedback/pages/attempt/attempt.html | 4 +- .../pages/respondents/respondents.html | 2 +- src/addon/mod/feedback/providers/helper.ts | 7 +- src/addon/mod/feedback/providers/sync.ts | 7 +- src/addon/mod/forum/providers/sync.ts | 5 +- src/addon/mod/glossary/providers/sync.ts | 5 +- .../lesson/pages/user-retake/user-retake.html | 2 +- src/addon/mod/lesson/providers/helper.ts | 5 +- src/addon/mod/lesson/providers/lesson-sync.ts | 5 +- .../index/addon-mod-page-index.html | 2 +- src/addon/mod/quiz/pages/review/review.html | 4 +- src/addon/mod/quiz/providers/quiz-sync.ts | 6 +- src/addon/mod/quiz/providers/quiz.ts | 9 +- .../mod/resource/providers/module-handler.ts | 12 +-- src/addon/mod/scorm/providers/scorm-sync.ts | 6 +- src/addon/mod/survey/providers/sync.ts | 6 +- src/addon/mod/wiki/providers/wiki-sync.ts | 6 +- src/addon/mod/workshop/providers/sync.ts | 5 +- src/addon/notes/providers/notes-sync.ts | 5 +- .../addon-user-profile-field-datetime.html | 2 +- src/assets/lang/en.json | 15 +++ src/classes/base-sync.ts | 7 +- src/components/file/core-file.html | 2 +- src/components/local-file/local-file.ts | 6 +- src/core/course/providers/sync.ts | 5 +- .../pages/course-preview/course-preview.html | 2 +- .../participants/core-user-participants.html | 2 +- src/lang/en.json | 17 +++- src/pipes/date-day-or-time.ts | 7 +- src/pipes/format-date.ts | 23 +++-- src/providers/utils/time.ts | 97 +++++++++++++++++++ upgrade.txt | 6 ++ 51 files changed, 294 insertions(+), 121 deletions(-) diff --git a/scripts/langindex.json b/scripts/langindex.json index e42df76d3..e72e9ebae 100644 --- a/scripts/langindex.json +++ b/scripts/langindex.json @@ -1654,6 +1654,21 @@ "core.sorry": "local_moodlemobileapp", "core.sortby": "moodle", "core.start": "grouptool", + "core.strftimedate": "langconfig", + "core.strftimedatefullshort": "langconfig", + "core.strftimedateshort": "langconfig", + "core.strftimedatetime": "langconfig", + "core.strftimedatetimeshort": "langconfig", + "core.strftimedaydate": "langconfig", + "core.strftimedaydatetime": "langconfig", + "core.strftimedayshort": "langconfig", + "core.strftimedaytime": "langconfig", + "core.strftimemonthyear": "langconfig", + "core.strftimerecent": "langconfig", + "core.strftimerecentfull": "langconfig", + "core.strftimetime": "langconfig", + "core.strftimetime12": "langconfig", + "core.strftimetime24": "langconfig", "core.submit": "moodle", "core.success": "moodle", "core.tablet": "local_moodlemobileapp", diff --git a/src/addon/block/myoverview/components/myoverview/myoverview.ts b/src/addon/block/myoverview/components/myoverview/myoverview.ts index 7e1668566..02f52c184 100644 --- a/src/addon/block/myoverview/components/myoverview/myoverview.ts +++ b/src/addon/block/myoverview/components/myoverview/myoverview.ts @@ -14,9 +14,9 @@ import { Component, OnInit, OnDestroy, ViewChild, Injector } from '@angular/core'; import { Searchbar } from 'ionic-angular'; -import * as moment from 'moment'; import { CoreEventsProvider } from '@providers/events'; import { CoreUtilsProvider } from '@providers/utils/utils'; +import { CoreTimeUtilsProvider } from '@providers/utils/time'; import { CoreSitesProvider } from '@providers/sites'; import { CoreCoursesProvider } from '@core/courses/providers/courses'; import { CoreCoursesHelperProvider } from '@core/courses/providers/helper'; @@ -74,7 +74,7 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem private courseCompletionProvider: AddonCourseCompletionProvider, private eventsProvider: CoreEventsProvider, private courseHelper: CoreCourseHelperProvider, private utils: CoreUtilsProvider, private courseOptionsDelegate: CoreCourseOptionsDelegate, private coursesHelper: CoreCoursesHelperProvider, - private sitesProvider: CoreSitesProvider) { + private sitesProvider: CoreSitesProvider, private timeUtils: CoreTimeUtilsProvider) { super(injector, 'AddonBlockMyOverviewComponent'); } @@ -251,7 +251,7 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem this.courses.favourite = []; this.courses.hidden = []; - const today = moment().unix(); + const today = this.timeUtils.timestamp(); courses.forEach((course) => { if (course.hidden) { this.courses.hidden.push(course); diff --git a/src/addon/block/timeline/components/events/addon-block-timeline-events.html b/src/addon/block/timeline/components/events/addon-block-timeline-events.html index 8e25b1f51..0cfddb603 100644 --- a/src/addon/block/timeline/components/events/addon-block-timeline-events.html +++ b/src/addon/block/timeline/components/events/addon-block-timeline-events.html @@ -1,6 +1,6 @@ -

{{ dayEvents.dayTimestamp * 1000 | coreFormatDate:"LL" }}

+

{{ dayEvents.dayTimestamp * 1000 | coreFormatDate:"strftimedayshort" }}

@@ -9,7 +9,7 @@

- {{event.timesort * 1000 | coreFormatDate:"LT" }} + {{event.timesort * 1000 | coreFormatDate:"strftimetime24" }}
diff --git a/src/addon/block/timeline/components/timeline/timeline.ts b/src/addon/block/timeline/components/timeline/timeline.ts index f58a5aa9d..ddffd3326 100644 --- a/src/addon/block/timeline/components/timeline/timeline.ts +++ b/src/addon/block/timeline/components/timeline/timeline.ts @@ -13,8 +13,8 @@ // limitations under the License. import { Component, OnInit, Injector } from '@angular/core'; -import * as moment from 'moment'; import { CoreUtilsProvider } from '@providers/utils/utils'; +import { CoreTimeUtilsProvider } from '@providers/utils/time'; import { CoreSitesProvider } from '@providers/sites'; import { CoreCoursesProvider } from '@core/courses/providers/courses'; import { CoreCoursesHelperProvider } from '@core/courses/providers/helper'; @@ -51,7 +51,8 @@ export class AddonBlockTimelineComponent extends CoreBlockBaseComponent implemen constructor(injector: Injector, private coursesProvider: CoreCoursesProvider, private utils: CoreUtilsProvider, private timelineProvider: AddonBlockTimelineProvider, private courseOptionsDelegate: CoreCourseOptionsDelegate, - private coursesHelper: CoreCoursesHelperProvider, private sitesProvider: CoreSitesProvider) { + private coursesHelper: CoreCoursesHelperProvider, private sitesProvider: CoreSitesProvider, + private timeUtils: CoreTimeUtilsProvider) { super(injector, 'AddonBlockTimelineComponent'); } @@ -151,7 +152,7 @@ export class AddonBlockTimelineComponent extends CoreBlockBaseComponent implemen */ protected fetchMyOverviewTimelineByCourses(): Promise { return this.coursesHelper.getUserCoursesWithOptions().then((courses) => { - const today = moment().unix(); + const today = this.timeUtils.timestamp(); courses = courses.filter((course) => { return course.startdate <= today && (!course.enddate || course.enddate >= today); }); diff --git a/src/addon/messages/pages/discussion/discussion.html b/src/addon/messages/pages/discussion/discussion.html index d307ec3c5..0c904ea55 100644 --- a/src/addon/messages/pages/discussion/discussion.html +++ b/src/addon/messages/pages/discussion/discussion.html @@ -28,7 +28,7 @@
- {{ message.timecreated | coreFormatDate: "LL" }} + {{ message.timecreated | coreFormatDate: "strftimedayshort" }}
@@ -43,7 +43,7 @@
{{ members[message.useridfrom].fullname }}
- {{ message.timecreated | coreFormatDate: "dftimedate" }} + {{ message.timecreated | coreFormatDate: "strftimetime" }} diff --git a/src/addon/messages/providers/sync.ts b/src/addon/messages/providers/sync.ts index 0e87d42f5..d8e46f6e8 100644 --- a/src/addon/messages/providers/sync.ts +++ b/src/addon/messages/providers/sync.ts @@ -22,6 +22,7 @@ import { AddonMessagesProvider } from './messages'; import { CoreUserProvider } from '@core/user/providers/user'; import { CoreEventsProvider } from '@providers/events'; import { CoreTextUtilsProvider } from '@providers/utils/text'; +import { CoreTimeUtilsProvider } from '@providers/utils/time'; import { CoreUtilsProvider } from '@providers/utils/utils'; import { TranslateService } from '@ngx-translate/core'; import { CoreSyncProvider } from '@providers/sync'; @@ -38,8 +39,8 @@ export class AddonMessagesSyncProvider extends CoreSyncBaseProvider { translate: TranslateService, syncProvider: CoreSyncProvider, textUtils: CoreTextUtilsProvider, private messagesOffline: AddonMessagesOfflineProvider, private eventsProvider: CoreEventsProvider, private messagesProvider: AddonMessagesProvider, private userProvider: CoreUserProvider, - private utils: CoreUtilsProvider) { - super('AddonMessagesSync', loggerProvider, sitesProvider, appProvider, syncProvider, textUtils, translate); + private utils: CoreUtilsProvider, timeUtils: CoreTimeUtilsProvider) { + super('AddonMessagesSync', loggerProvider, sitesProvider, appProvider, syncProvider, textUtils, translate, timeUtils); } /** diff --git a/src/addon/mod/assign/components/index/index.ts b/src/addon/mod/assign/components/index/index.ts index f46e35bc7..7248083ca 100644 --- a/src/addon/mod/assign/components/index/index.ts +++ b/src/addon/mod/assign/components/index/index.ts @@ -21,7 +21,6 @@ import { AddonModAssignProvider } from '../../providers/assign'; import { AddonModAssignHelperProvider } from '../../providers/helper'; import { AddonModAssignOfflineProvider } from '../../providers/assign-offline'; import { AddonModAssignSyncProvider } from '../../providers/assign-sync'; -import * as moment from 'moment'; import { AddonModAssignSubmissionComponent } from '../submission/submission'; /** @@ -178,10 +177,8 @@ export class AddonModAssignIndexComponent extends CoreCourseModuleMainActivityCo if (this.assign.cutoffdate) { if (this.assign.cutoffdate > time) { - const dateFormat = this.translate.instant('core.dfmediumdate'); - this.lateSubmissions = this.translate.instant('addon.mod_assign.latesubmissionsaccepted', - {$a: moment(this.assign.cutoffdate * 1000).format(dateFormat)}); + {$a: this.timeUtils.userDate(this.assign.cutoffdate * 1000)}); } else { this.lateSubmissions = this.translate.instant('addon.mod_assign.nomoresubmissionsaccepted'); } diff --git a/src/addon/mod/assign/components/submission/addon-mod-assign-submission.html b/src/addon/mod/assign/components/submission/addon-mod-assign-submission.html index 88260c55d..ea03450af 100644 --- a/src/addon/mod/assign/components/submission/addon-mod-assign-submission.html +++ b/src/addon/mod/assign/components/submission/addon-mod-assign-submission.html @@ -29,7 +29,7 @@

{{ 'addon.mod_assign.timemodified' | translate }}

-

{{ userSubmission.timemodified * 1000 | coreFormatDate:"dfmediumdate" }}

+

{{ userSubmission.timemodified * 1000 | coreFormatDate }}

@@ -44,18 +44,18 @@

{{ 'addon.mod_assign.duedate' | translate }}

-

{{ assign.duedate * 1000 | coreFormatDate:"dfmediumdate" }}

+

{{ assign.duedate * 1000 | coreFormatDate }}

{{ 'addon.mod_assign.duedateno' | translate }}

{{ 'addon.mod_assign.cutoffdate' | translate }}

-

{{ assign.cutoffdate * 1000 | coreFormatDate:"dfmediumdate" }}

+

{{ assign.cutoffdate * 1000 | coreFormatDate }}

{{ 'addon.mod_assign.extensionduedate' | translate }}

-

{{ lastAttempt.extensionduedate * 1000 | coreFormatDate:"dfmediumdate" }}

+

{{ lastAttempt.extensionduedate * 1000 | coreFormatDate }}

@@ -212,7 +212,7 @@

{{ 'addon.mod_assign.gradedby' | translate }}

{{ grader.fullname }}

-

{{ feedback.gradeddate * 1000 | coreFormatDate:"dfmediumdate" }}

+

{{ feedback.gradeddate * 1000 | coreFormatDate }}

diff --git a/src/addon/mod/assign/components/submission/submission.ts b/src/addon/mod/assign/components/submission/submission.ts index b4a66e101..c288f1b22 100644 --- a/src/addon/mod/assign/components/submission/submission.ts +++ b/src/addon/mod/assign/components/submission/submission.ts @@ -32,7 +32,6 @@ import { CoreUserProvider } from '@core/user/providers/user'; import { AddonModAssignProvider } from '../../providers/assign'; import { AddonModAssignHelperProvider } from '../../providers/helper'; import { AddonModAssignOfflineProvider } from '../../providers/assign-offline'; -import * as moment from 'moment'; import { CoreTabsComponent } from '@components/tabs/tabs'; import { CoreSplitViewComponent } from '@components/split-view/split-view'; import { AddonModAssignSubmissionPluginComponent } from '../submission-plugin/submission-plugin'; @@ -383,7 +382,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy { this.assign = assign; if (assign.allowsubmissionsfromdate && assign.allowsubmissionsfromdate >= time) { - this.fromDate = moment(assign.allowsubmissionsfromdate * 1000).format(this.translate.instant('core.dfmediumdate')); + this.fromDate = this.timeUtils.userDate(assign.allowsubmissionsfromdate * 1000); } this.currentAttempt = 0; diff --git a/src/addon/mod/assign/providers/assign-sync.ts b/src/addon/mod/assign/providers/assign-sync.ts index 368eba7de..96627a1cc 100644 --- a/src/addon/mod/assign/providers/assign-sync.ts +++ b/src/addon/mod/assign/providers/assign-sync.ts @@ -20,6 +20,7 @@ import { CoreLoggerProvider } from '@providers/logger'; import { CoreSitesProvider } from '@providers/sites'; import { CoreSyncProvider } from '@providers/sync'; import { CoreTextUtilsProvider } from '@providers/utils/text'; +import { CoreTimeUtilsProvider } from '@providers/utils/time'; import { CoreUtilsProvider } from '@providers/utils/utils'; import { CoreCourseProvider } from '@core/course/providers/course'; import { CoreGradesHelperProvider } from '@core/grades/providers/helper'; @@ -60,9 +61,10 @@ export class AddonModAssignSyncProvider extends CoreSyncBaseProvider { private courseProvider: CoreCourseProvider, private eventsProvider: CoreEventsProvider, private assignProvider: AddonModAssignProvider, private assignOfflineProvider: AddonModAssignOfflineProvider, private utils: CoreUtilsProvider, private submissionDelegate: AddonModAssignSubmissionDelegate, - private gradesHelper: CoreGradesHelperProvider) { + private gradesHelper: CoreGradesHelperProvider, timeUtils: CoreTimeUtilsProvider) { - super('AddonModAssignSyncProvider', loggerProvider, sitesProvider, appProvider, syncProvider, textUtils, translate); + super('AddonModAssignSyncProvider', loggerProvider, sitesProvider, appProvider, syncProvider, textUtils, translate, + timeUtils); this.componentTranslate = courseProvider.translateModuleName('assign'); } diff --git a/src/addon/mod/chat/components/index/index.ts b/src/addon/mod/chat/components/index/index.ts index e21d5623a..34f3bc248 100644 --- a/src/addon/mod/chat/components/index/index.ts +++ b/src/addon/mod/chat/components/index/index.ts @@ -17,7 +17,6 @@ import { NavController } from 'ionic-angular'; import { CoreCourseModuleMainActivityComponent } from '@core/course/classes/main-activity-component'; import { CoreTimeUtilsProvider } from '@providers/utils/time'; import { AddonModChatProvider } from '../../providers/chat'; -import * as moment from 'moment'; /** * Component that displays a chat. @@ -73,7 +72,7 @@ export class AddonModChatIndexComponent extends CoreCourseModuleMainActivityComp if (chat.chattime && chat.schedule > 0 && span > 0) { this.chatInfo = { - date: moment(chat.chattime * 1000).format('LLL'), + date: this.timeUtils.userDate(chat.chattime * 1000), fromnow: this.timeUtils.formatTime(span) }; } else { diff --git a/src/addon/mod/chat/pages/chat/chat.html b/src/addon/mod/chat/pages/chat/chat.html index 02eb8e71a..47f744618 100644 --- a/src/addon/mod/chat/pages/chat/chat.html +++ b/src/addon/mod/chat/pages/chat/chat.html @@ -15,19 +15,19 @@
- {{ message.timestamp * 1000 | coreFormatDate:"dfdayweekmonth" }} + {{ message.timestamp * 1000 | coreFormatDate:"strftimedayshort" }}
- {{ message.timestamp * 1000 | coreFormatDate:"dftimedate" }} {{ 'addon.mod_chat.messageenter' | translate:{$a: message.userfullname} }} + {{ message.timestamp * 1000 | coreFormatDate:"strftimetime" }} {{ 'addon.mod_chat.messageenter' | translate:{$a: message.userfullname} }}
- {{ message.timestamp * 1000 | coreFormatDate:"dftimedate" }} {{ 'addon.mod_chat.messageexit' | translate:{$a: message.userfullname} }} + {{ message.timestamp * 1000 | coreFormatDate:"strftimetime" }} {{ 'addon.mod_chat.messageexit' | translate:{$a: message.userfullname} }}
@@ -40,7 +40,7 @@

-

{{ message.timestamp * 1000 | coreFormatDate:"dftimedate" }}

+

{{ message.timestamp * 1000 | coreFormatDate:"strftimetime" }}

diff --git a/src/addon/mod/choice/components/index/index.ts b/src/addon/mod/choice/components/index/index.ts index 358a0ac6e..fe583dd04 100644 --- a/src/addon/mod/choice/components/index/index.ts +++ b/src/addon/mod/choice/components/index/index.ts @@ -14,11 +14,11 @@ import { Component, Optional, Injector } from '@angular/core'; import { Content } from 'ionic-angular'; +import { CoreTimeUtilsProvider } from '@providers/utils/time'; import { CoreCourseModuleMainActivityComponent } from '@core/course/classes/main-activity-component'; import { AddonModChoiceProvider } from '../../providers/choice'; import { AddonModChoiceOfflineProvider } from '../../providers/offline'; import { AddonModChoiceSyncProvider } from '../../providers/sync'; -import * as moment from 'moment'; /** * Component that displays a choice. @@ -50,7 +50,8 @@ export class AddonModChoiceIndexComponent extends CoreCourseModuleMainActivityCo protected now: number; constructor(injector: Injector, private choiceProvider: AddonModChoiceProvider, @Optional() content: Content, - private choiceOffline: AddonModChoiceOfflineProvider, private choiceSync: AddonModChoiceSyncProvider) { + private choiceOffline: AddonModChoiceOfflineProvider, private choiceSync: AddonModChoiceSyncProvider, + private timeUtils: CoreTimeUtilsProvider) { super(injector, content); } @@ -122,9 +123,9 @@ export class AddonModChoiceIndexComponent extends CoreCourseModuleMainActivityCo return this.choiceProvider.getChoice(this.courseId, this.module.id).then((choice) => { this.choice = choice; this.choice.timeopen = parseInt(choice.timeopen) * 1000; - this.choice.openTimeReadable = moment(choice.timeopen).format('LLL'); + this.choice.openTimeReadable = this.timeUtils.userDate(choice.timeopen); this.choice.timeclose = parseInt(choice.timeclose) * 1000; - this.choice.closeTimeReadable = moment(choice.timeclose).format('LLL'); + this.choice.closeTimeReadable = this.timeUtils.userDate(choice.timeclose); this.description = choice.intro || choice.description; this.choiceNotOpenYet = choice.timeopen && choice.timeopen > this.now; diff --git a/src/addon/mod/choice/providers/sync.ts b/src/addon/mod/choice/providers/sync.ts index 48efe6663..01635c5d4 100644 --- a/src/addon/mod/choice/providers/sync.ts +++ b/src/addon/mod/choice/providers/sync.ts @@ -19,6 +19,7 @@ import { CoreSitesProvider } from '@providers/sites'; import { CoreAppProvider } from '@providers/app'; import { CoreUtilsProvider } from '@providers/utils/utils'; import { CoreTextUtilsProvider } from '@providers/utils/text'; +import { CoreTimeUtilsProvider } from '@providers/utils/time'; import { AddonModChoiceOfflineProvider } from './offline'; import { AddonModChoiceProvider } from './choice'; import { CoreEventsProvider } from '@providers/events'; @@ -39,8 +40,10 @@ export class AddonModChoiceSyncProvider extends CoreSyncBaseProvider { protected appProvider: CoreAppProvider, private choiceOffline: AddonModChoiceOfflineProvider, private eventsProvider: CoreEventsProvider, private choiceProvider: AddonModChoiceProvider, translate: TranslateService, private utils: CoreUtilsProvider, protected textUtils: CoreTextUtilsProvider, - courseProvider: CoreCourseProvider, syncProvider: CoreSyncProvider) { - super('AddonModChoiceSyncProvider', loggerProvider, sitesProvider, appProvider, syncProvider, textUtils, translate); + courseProvider: CoreCourseProvider, syncProvider: CoreSyncProvider, timeUtils: CoreTimeUtilsProvider) { + super('AddonModChoiceSyncProvider', loggerProvider, sitesProvider, appProvider, syncProvider, textUtils, translate, + timeUtils); + this.componentTranslate = courseProvider.translateModuleName('choice'); } diff --git a/src/addon/mod/data/components/action/addon-mod-data-action.html b/src/addon/mod/data/components/action/addon-mod-data-action.html index 5645b0c3c..2faa09162 100644 --- a/src/addon/mod/data/components/action/addon-mod-data-action.html +++ b/src/addon/mod/data/components/action/addon-mod-data-action.html @@ -24,8 +24,8 @@ -{{ entry.timecreated * 1000 | coreFormatDate:"dffulldate" }} -{{ entry.timemodified * 1000 | coreFormatDate:"dffulldate" }} +{{ entry.timecreated * 1000 | coreFormatDate }} +{{ entry.timemodified * 1000 | coreFormatDate }} diff --git a/src/addon/mod/data/components/index/index.ts b/src/addon/mod/data/components/index/index.ts index 71f922666..e67b34d2e 100644 --- a/src/addon/mod/data/components/index/index.ts +++ b/src/addon/mod/data/components/index/index.ts @@ -24,7 +24,6 @@ import { AddonModDataHelperProvider } from '../../providers/helper'; import { AddonModDataOfflineProvider } from '../../providers/offline'; import { AddonModDataSyncProvider } from '../../providers/sync'; import { AddonModDataComponentsModule } from '../components.module'; -import * as moment from 'moment'; /** * Component that displays a data index page. @@ -186,11 +185,10 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp this.timeAvailableFrom = this.data.timeavailablefrom && time < this.data.timeavailablefrom ? parseInt(this.data.timeavailablefrom, 10) * 1000 : false; - this.timeAvailableFromReadable = this.timeAvailableFrom ? - moment(this.timeAvailableFrom).format('LLL') : false; + this.timeAvailableFromReadable = this.timeAvailableFrom ? this.timeUtils.userDate(this.timeAvailableFrom) : false; this.timeAvailableTo = this.data.timeavailableto && time > this.data.timeavailableto ? parseInt(this.data.timeavailableto, 10) * 1000 : false; - this.timeAvailableToReadable = this.timeAvailableTo ? moment(this.timeAvailableTo).format('LLL') : false; + this.timeAvailableToReadable = this.timeAvailableTo ? this.timeUtils.userDate(this.timeAvailableTo) : false; this.isEmpty = true; this.groupInfo = null; diff --git a/src/addon/mod/data/fields/date/component/addon-mod-data-field-date.html b/src/addon/mod/data/fields/date/component/addon-mod-data-field-date.html index 9d69823cc..674dfb0df 100644 --- a/src/addon/mod/data/fields/date/component/addon-mod-data-field-date.html +++ b/src/addon/mod/data/fields/date/component/addon-mod-data-field-date.html @@ -10,5 +10,5 @@
- + diff --git a/src/addon/mod/data/providers/sync.ts b/src/addon/mod/data/providers/sync.ts index 37ac1e714..6e2a90128 100644 --- a/src/addon/mod/data/providers/sync.ts +++ b/src/addon/mod/data/providers/sync.ts @@ -19,6 +19,7 @@ import { CoreSyncBaseProvider } from '@classes/base-sync'; import { CoreAppProvider } from '@providers/app'; import { CoreUtilsProvider } from '@providers/utils/utils'; import { CoreTextUtilsProvider } from '@providers/utils/text'; +import { CoreTimeUtilsProvider } from '@providers/utils/time'; import { AddonModDataOfflineProvider } from './offline'; import { AddonModDataProvider } from './data'; import { AddonModDataHelperProvider } from './helper'; @@ -40,9 +41,11 @@ export class AddonModDataSyncProvider extends CoreSyncBaseProvider { protected appProvider: CoreAppProvider, private dataOffline: AddonModDataOfflineProvider, private eventsProvider: CoreEventsProvider, private dataProvider: AddonModDataProvider, protected translate: TranslateService, private utils: CoreUtilsProvider, courseProvider: CoreCourseProvider, - syncProvider: CoreSyncProvider, protected textUtils: CoreTextUtilsProvider, + syncProvider: CoreSyncProvider, protected textUtils: CoreTextUtilsProvider, timeUtils: CoreTimeUtilsProvider, private dataHelper: AddonModDataHelperProvider) { - super('AddonModDataSyncProvider', loggerProvider, sitesProvider, appProvider, syncProvider, textUtils, translate); + super('AddonModDataSyncProvider', loggerProvider, sitesProvider, appProvider, syncProvider, textUtils, translate, + timeUtils); + this.componentTranslate = courseProvider.translateModuleName('data'); } diff --git a/src/addon/mod/feedback/components/index/index.ts b/src/addon/mod/feedback/components/index/index.ts index 14fbf05c3..1eb116187 100644 --- a/src/addon/mod/feedback/components/index/index.ts +++ b/src/addon/mod/feedback/components/index/index.ts @@ -15,12 +15,12 @@ import { Component, Input, Optional, Injector, ViewChild } from '@angular/core'; import { Content, NavController } from 'ionic-angular'; import { CoreGroupInfo, CoreGroupsProvider } from '@providers/groups'; +import { CoreTimeUtilsProvider } from '@providers/utils/time'; import { CoreCourseModuleMainActivityComponent } from '@core/course/classes/main-activity-component'; import { AddonModFeedbackProvider } from '../../providers/feedback'; import { AddonModFeedbackHelperProvider } from '../../providers/helper'; import { AddonModFeedbackOfflineProvider } from '../../providers/offline'; import { AddonModFeedbackSyncProvider } from '../../providers/sync'; -import * as moment from 'moment'; import { CoreTabsComponent } from '@components/tabs/tabs'; /** @@ -71,7 +71,7 @@ export class AddonModFeedbackIndexComponent extends CoreCourseModuleMainActivity constructor(injector: Injector, private feedbackProvider: AddonModFeedbackProvider, @Optional() content: Content, private feedbackOffline: AddonModFeedbackOfflineProvider, private groupsProvider: CoreGroupsProvider, private feedbackSync: AddonModFeedbackSyncProvider, private navCtrl: NavController, - private feedbackHelper: AddonModFeedbackHelperProvider) { + private feedbackHelper: AddonModFeedbackHelperProvider, private timeUtils: CoreTimeUtilsProvider) { super(injector, content); // Listen for form submit events. @@ -207,11 +207,9 @@ export class AddonModFeedbackIndexComponent extends CoreCourseModuleMainActivity if (accessData.canedititems) { this.overview.timeopen = parseInt(this.feedback.timeopen) * 1000 || 0; - this.overview.openTimeReadable = this.overview.timeopen ? - moment(this.overview.timeopen).format('LLL') : ''; + this.overview.openTimeReadable = this.overview.timeopen ? this.timeUtils.userDate(this.overview.timeopen) : ''; this.overview.timeclose = parseInt(this.feedback.timeclose) * 1000 || 0; - this.overview.closeTimeReadable = this.overview.timeclose ? - moment(this.overview.timeclose).format('LLL') : ''; + this.overview.closeTimeReadable = this.overview.timeclose ? this.timeUtils.userDate(this.overview.timeclose) : ''; } if (accessData.canviewanalysis) { // Get groups (only for teachers). diff --git a/src/addon/mod/feedback/pages/attempt/attempt.html b/src/addon/mod/feedback/pages/attempt/attempt.html index 01ec496c8..e071278a0 100644 --- a/src/addon/mod/feedback/pages/attempt/attempt.html +++ b/src/addon/mod/feedback/pages/attempt/attempt.html @@ -9,12 +9,12 @@

{{attempt.fullname}}

-

{{attempt.timemodified * 1000 | coreFormatDate:"LLL"}}

+

{{attempt.timemodified * 1000 | coreFormatDate }}

{{ 'addon.mod_feedback.response_nr' |translate }}: {{attempt.number}} ({{ 'addon.mod_feedback.anonymous' |translate }})

-

{{attempt.timemodified * 1000 | coreFormatDate:"LLL"}}

+

{{attempt.timemodified * 1000 | coreFormatDate }}

diff --git a/src/addon/mod/feedback/pages/respondents/respondents.html b/src/addon/mod/feedback/pages/respondents/respondents.html index 115e9a13c..ca7b4a7a7 100644 --- a/src/addon/mod/feedback/pages/respondents/respondents.html +++ b/src/addon/mod/feedback/pages/respondents/respondents.html @@ -24,7 +24,7 @@

-

{{attempt.timemodified * 1000 | coreFormatDate: "LLL"}}

+

{{attempt.timemodified * 1000 | coreFormatDate }}

diff --git a/src/addon/mod/feedback/providers/helper.ts b/src/addon/mod/feedback/providers/helper.ts index 87d75b0bb..f0ac01d0c 100644 --- a/src/addon/mod/feedback/providers/helper.ts +++ b/src/addon/mod/feedback/providers/helper.ts @@ -17,8 +17,8 @@ import { NavController, ViewController } from 'ionic-angular'; import { AddonModFeedbackProvider } from './feedback'; import { CoreUserProvider } from '@core/user/providers/user'; import { CoreTextUtilsProvider } from '@providers/utils/text'; +import { CoreTimeUtilsProvider } from '@providers/utils/time'; import { TranslateService } from '@ngx-translate/core'; -import * as moment from 'moment'; /** * Service that provides helper functions for feedbacks. @@ -31,7 +31,8 @@ export class AddonModFeedbackHelperProvider { protected MODE_CATEGORY = 3; constructor(protected feedbackProvider: AddonModFeedbackProvider, protected userProvider: CoreUserProvider, - protected textUtils: CoreTextUtilsProvider, protected translate: TranslateService) { + protected textUtils: CoreTextUtilsProvider, protected translate: TranslateService, + protected timeUtils: CoreTimeUtilsProvider) { } /** @@ -278,7 +279,7 @@ export class AddonModFeedbackHelperProvider { } else if (type == this.MODE_RESPONSETIME) { item.value = '__CURRENT__TIMESTAMP__'; const tempValue = typeof item.rawValue != 'undefined' ? item.rawValue * 1000 : new Date().getTime(); - item.presentation = moment(tempValue).format('LLL'); + item.presentation = this.timeUtils.userDate(tempValue); } else { // Errors on item, return false. return false; diff --git a/src/addon/mod/feedback/providers/sync.ts b/src/addon/mod/feedback/providers/sync.ts index 21d3b34f8..4aca43570 100644 --- a/src/addon/mod/feedback/providers/sync.ts +++ b/src/addon/mod/feedback/providers/sync.ts @@ -19,6 +19,7 @@ import { CoreSyncBaseProvider } from '@classes/base-sync'; import { CoreAppProvider } from '@providers/app'; import { CoreUtilsProvider } from '@providers/utils/utils'; import { CoreTextUtilsProvider } from '@providers/utils/text'; +import { CoreTimeUtilsProvider } from '@providers/utils/time'; import { AddonModFeedbackOfflineProvider } from './offline'; import { AddonModFeedbackProvider } from './feedback'; import { CoreEventsProvider } from '@providers/events'; @@ -39,8 +40,10 @@ export class AddonModFeedbackSyncProvider extends CoreSyncBaseProvider { protected appProvider: CoreAppProvider, private feedbackOffline: AddonModFeedbackOfflineProvider, private eventsProvider: CoreEventsProvider, private feedbackProvider: AddonModFeedbackProvider, protected translate: TranslateService, private utils: CoreUtilsProvider, protected textUtils: CoreTextUtilsProvider, - courseProvider: CoreCourseProvider, syncProvider: CoreSyncProvider) { - super('AddonModFeedbackSyncProvider', loggerProvider, sitesProvider, appProvider, syncProvider, textUtils, translate); + courseProvider: CoreCourseProvider, syncProvider: CoreSyncProvider, timeUtils: CoreTimeUtilsProvider) { + super('AddonModFeedbackSyncProvider', loggerProvider, sitesProvider, appProvider, syncProvider, textUtils, translate, + timeUtils); + this.componentTranslate = courseProvider.translateModuleName('feedback'); } diff --git a/src/addon/mod/forum/providers/sync.ts b/src/addon/mod/forum/providers/sync.ts index 127843475..76fc0c4ae 100644 --- a/src/addon/mod/forum/providers/sync.ts +++ b/src/addon/mod/forum/providers/sync.ts @@ -23,6 +23,7 @@ import { CoreEventsProvider } from '@providers/events'; import { CoreSitesProvider } from '@providers/sites'; import { CoreSyncProvider } from '@providers/sync'; import { CoreTextUtilsProvider } from '@providers/utils/text'; +import { CoreTimeUtilsProvider } from '@providers/utils/time'; import { CoreUtilsProvider } from '@providers/utils/utils'; import { AddonModForumProvider } from './forum'; import { AddonModForumHelperProvider } from './helper'; @@ -47,13 +48,15 @@ export class AddonModForumSyncProvider extends CoreSyncBaseProvider { sitesProvider: CoreSitesProvider, syncProvider: CoreSyncProvider, textUtils: CoreTextUtilsProvider, + timeUtils: CoreTimeUtilsProvider, private uploaderProvider: CoreFileUploaderProvider, private utils: CoreUtilsProvider, private forumProvider: AddonModForumProvider, private forumHelper: AddonModForumHelperProvider, private forumOffline: AddonModForumOfflineProvider) { - super('AddonModForumSyncProvider', loggerProvider, sitesProvider, appProvider, syncProvider, textUtils, translate); + super('AddonModForumSyncProvider', loggerProvider, sitesProvider, appProvider, syncProvider, textUtils, translate, + timeUtils); this.componentTranslate = courseProvider.translateModuleName('forum'); } diff --git a/src/addon/mod/glossary/providers/sync.ts b/src/addon/mod/glossary/providers/sync.ts index 00350ef75..ab748ab9d 100644 --- a/src/addon/mod/glossary/providers/sync.ts +++ b/src/addon/mod/glossary/providers/sync.ts @@ -23,6 +23,7 @@ import { CoreEventsProvider } from '@providers/events'; import { CoreSitesProvider } from '@providers/sites'; import { CoreSyncProvider } from '@providers/sync'; import { CoreTextUtilsProvider } from '@providers/utils/text'; +import { CoreTimeUtilsProvider } from '@providers/utils/time'; import { CoreUtilsProvider } from '@providers/utils/utils'; import { AddonModGlossaryProvider } from './glossary'; import { AddonModGlossaryHelperProvider } from './helper'; @@ -46,13 +47,15 @@ export class AddonModGlossarySyncProvider extends CoreSyncBaseProvider { sitesProvider: CoreSitesProvider, syncProvider: CoreSyncProvider, textUtils: CoreTextUtilsProvider, + timeUtils: CoreTimeUtilsProvider, private uploaderProvider: CoreFileUploaderProvider, private utils: CoreUtilsProvider, private glossaryProvider: AddonModGlossaryProvider, private glossaryHelper: AddonModGlossaryHelperProvider, private glossaryOffline: AddonModGlossaryOfflineProvider) { - super('AddonModGlossarySyncProvider', loggerProvider, sitesProvider, appProvider, syncProvider, textUtils, translate); + super('AddonModGlossarySyncProvider', loggerProvider, sitesProvider, appProvider, syncProvider, textUtils, translate, + timeUtils); this.componentTranslate = courseProvider.translateModuleName('glossary'); } diff --git a/src/addon/mod/lesson/pages/user-retake/user-retake.html b/src/addon/mod/lesson/pages/user-retake/user-retake.html index 1f28b5e6d..3b35e37e4 100644 --- a/src/addon/mod/lesson/pages/user-retake/user-retake.html +++ b/src/addon/mod/lesson/pages/user-retake/user-retake.html @@ -46,7 +46,7 @@

{{ 'addon.mod_lesson.completed' | translate }}

-

{{ retake.userstats.completed * 1000 | coreFormatDate:"dfmediumdate" }}

+

{{ retake.userstats.completed * 1000 | coreFormatDate }}

diff --git a/src/addon/mod/lesson/providers/helper.ts b/src/addon/mod/lesson/providers/helper.ts index 3f7be38d2..e88652f6c 100644 --- a/src/addon/mod/lesson/providers/helper.ts +++ b/src/addon/mod/lesson/providers/helper.ts @@ -19,7 +19,6 @@ import { CoreDomUtilsProvider } from '@providers/utils/dom'; import { CoreTextUtilsProvider } from '@providers/utils/text'; import { CoreTimeUtilsProvider } from '@providers/utils/time'; import { AddonModLessonProvider } from './lesson'; -import * as moment from 'moment'; /** * Helper service that provides some features for quiz. @@ -430,7 +429,7 @@ export class AddonModLessonHelperProvider { if (hasGrade) { data.grade = this.translate.instant('core.percentagenumber', {$a: retake.grade}); } - data.timestart = moment(retake.timestart * 1000).format('LLL'); + data.timestart = this.timeUtils.userDate(retake.timestart * 1000); if (includeDuration) { data.duration = this.timeUtils.formatTime(retake.timeend - retake.timestart); } @@ -438,7 +437,7 @@ export class AddonModLessonHelperProvider { // The user has not completed the retake. data.grade = this.translate.instant('addon.mod_lesson.notcompleted'); if (retake.timestart) { - data.timestart = moment(retake.timestart * 1000).format('LLL'); + data.timestart = this.timeUtils.userDate(retake.timestart * 1000); } } diff --git a/src/addon/mod/lesson/providers/lesson-sync.ts b/src/addon/mod/lesson/providers/lesson-sync.ts index 5afb4f829..de7e2ef7c 100644 --- a/src/addon/mod/lesson/providers/lesson-sync.ts +++ b/src/addon/mod/lesson/providers/lesson-sync.ts @@ -85,10 +85,11 @@ export class AddonModLessonSyncProvider extends CoreSyncBaseProvider { syncProvider: CoreSyncProvider, textUtils: CoreTextUtilsProvider, translate: TranslateService, courseProvider: CoreCourseProvider, private eventsProvider: CoreEventsProvider, private lessonProvider: AddonModLessonProvider, private lessonOfflineProvider: AddonModLessonOfflineProvider, - private prefetchHandler: AddonModLessonPrefetchHandler, private timeUtils: CoreTimeUtilsProvider, + private prefetchHandler: AddonModLessonPrefetchHandler, timeUtils: CoreTimeUtilsProvider, private utils: CoreUtilsProvider, private urlUtils: CoreUrlUtilsProvider) { - super('AddonModLessonSyncProvider', loggerProvider, sitesProvider, appProvider, syncProvider, textUtils, translate); + super('AddonModLessonSyncProvider', loggerProvider, sitesProvider, appProvider, syncProvider, textUtils, translate, + timeUtils); this.componentTranslate = courseProvider.translateModuleName('lesson'); diff --git a/src/addon/mod/page/components/index/addon-mod-page-index.html b/src/addon/mod/page/components/index/addon-mod-page-index.html index 4f99c5dac..3919124c4 100644 --- a/src/addon/mod/page/components/index/addon-mod-page-index.html +++ b/src/addon/mod/page/components/index/addon-mod-page-index.html @@ -17,7 +17,7 @@

- {{ 'core.lastmodified' | translate}}: {{ page.timemodified * 1000 | coreFormatDate: "dfmediumdate" }} + {{ 'core.lastmodified' | translate}}: {{ page.timemodified * 1000 | coreFormatDate }}

diff --git a/src/addon/mod/quiz/pages/review/review.html b/src/addon/mod/quiz/pages/review/review.html index 49670516f..f2e4cab77 100644 --- a/src/addon/mod/quiz/pages/review/review.html +++ b/src/addon/mod/quiz/pages/review/review.html @@ -24,7 +24,7 @@

{{ 'addon.mod_quiz.startedon' | translate }}

-

{{ attempt.timestart * 1000 | coreFormatDate:"dfmediumdate" }}

+

{{ attempt.timestart * 1000 | coreFormatDate }}

{{ 'addon.mod_quiz.attemptstate' | translate }}

@@ -32,7 +32,7 @@

{{ 'addon.mod_quiz.completedon' | translate }}

-

{{ attempt.timefinish * 1000 | coreFormatDate:"dfmediumdate" }}

+

{{ attempt.timefinish * 1000 | coreFormatDate }}

{{ 'addon.mod_quiz.timetaken' | translate }}

diff --git a/src/addon/mod/quiz/providers/quiz-sync.ts b/src/addon/mod/quiz/providers/quiz-sync.ts index 7e25e3891..9c27f22b5 100644 --- a/src/addon/mod/quiz/providers/quiz-sync.ts +++ b/src/addon/mod/quiz/providers/quiz-sync.ts @@ -20,6 +20,7 @@ import { CoreLoggerProvider } from '@providers/logger'; import { CoreSitesProvider } from '@providers/sites'; import { CoreSyncProvider } from '@providers/sync'; import { CoreTextUtilsProvider } from '@providers/utils/text'; +import { CoreTimeUtilsProvider } from '@providers/utils/time'; import { CoreCourseProvider } from '@core/course/providers/course'; import { CoreQuestionProvider } from '@core/question/providers/question'; import { CoreQuestionDelegate } from '@core/question/providers/delegate'; @@ -57,12 +58,13 @@ export class AddonModQuizSyncProvider extends CoreSyncBaseProvider { constructor(loggerProvider: CoreLoggerProvider, sitesProvider: CoreSitesProvider, appProvider: CoreAppProvider, syncProvider: CoreSyncProvider, textUtils: CoreTextUtilsProvider, translate: TranslateService, - courseProvider: CoreCourseProvider, private eventsProvider: CoreEventsProvider, + courseProvider: CoreCourseProvider, private eventsProvider: CoreEventsProvider, timeUtils: CoreTimeUtilsProvider, private quizProvider: AddonModQuizProvider, private quizOfflineProvider: AddonModQuizOfflineProvider, private prefetchHandler: AddonModQuizPrefetchHandler, private questionProvider: CoreQuestionProvider, private questionDelegate: CoreQuestionDelegate) { - super('AddonModQuizSyncProvider', loggerProvider, sitesProvider, appProvider, syncProvider, textUtils, translate); + super('AddonModQuizSyncProvider', loggerProvider, sitesProvider, appProvider, syncProvider, textUtils, translate, + timeUtils); this.componentTranslate = courseProvider.translateModuleName('quiz'); } diff --git a/src/addon/mod/quiz/providers/quiz.ts b/src/addon/mod/quiz/providers/quiz.ts index a14ffedc3..a3c8d87be 100644 --- a/src/addon/mod/quiz/providers/quiz.ts +++ b/src/addon/mod/quiz/providers/quiz.ts @@ -26,7 +26,6 @@ import { CoreGradesHelperProvider } from '@core/grades/providers/helper'; import { CoreQuestionDelegate } from '@core/question/providers/delegate'; import { AddonModQuizAccessRuleDelegate } from './access-rules-delegate'; import { AddonModQuizOfflineProvider } from './quiz-offline'; -import * as moment from 'moment'; /** * Service that provides some features for quiz. @@ -287,9 +286,9 @@ export class AddonModQuizProvider { const dueDate = this.getAttemptDueDate(quiz, attempt); if (attempt.state === AddonModQuizProvider.ATTEMPT_OVERDUE) { - return this.translate.instant('addon.mod_quiz.overduemustbesubmittedby', {$a: moment(dueDate).format('LLL')}); + return this.translate.instant('addon.mod_quiz.overduemustbesubmittedby', {$a: this.timeUtils.userDate(dueDate)}); } else if (dueDate) { - return this.translate.instant('addon.mod_quiz.mustbesubmittedby', {$a: moment(dueDate).format('LLL')}); + return this.translate.instant('addon.mod_quiz.mustbesubmittedby', {$a: this.timeUtils.userDate(dueDate)}); } } @@ -317,7 +316,7 @@ export class AddonModQuizProvider { if (dueDate) { sentences.push(this.translate.instant('addon.mod_quiz.stateoverduedetails', - {$a: moment(dueDate).format('LLL')})); + {$a: this.timeUtils.userDate(dueDate)})); } return sentences; @@ -326,7 +325,7 @@ export class AddonModQuizProvider { return [ this.translate.instant('addon.mod_quiz.statefinished'), this.translate.instant('addon.mod_quiz.statefinisheddetails', - {$a: moment(attempt.timefinish * 1000).format('LLL')}) + {$a: this.timeUtils.userDate(attempt.timefinish * 1000)}) ]; case AddonModQuizProvider.ATTEMPT_ABANDONED: diff --git a/src/addon/mod/resource/providers/module-handler.ts b/src/addon/mod/resource/providers/module-handler.ts index c29415ad7..94267ed38 100644 --- a/src/addon/mod/resource/providers/module-handler.ts +++ b/src/addon/mod/resource/providers/module-handler.ts @@ -22,9 +22,9 @@ import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@core/cour import { CoreCourseProvider } from '@core/course/providers/course'; import { CoreMimetypeUtilsProvider } from '@providers/utils/mimetype'; import { CoreTextUtilsProvider } from '@providers/utils/text'; +import { CoreTimeUtilsProvider } from '@providers/utils/time'; import { CoreCourseModulePrefetchDelegate } from '@core/course/providers/module-prefetch-delegate'; import { CoreConstants } from '@core/constants'; -import * as moment from 'moment'; /** * Handler to support resource modules. @@ -51,7 +51,7 @@ export class AddonModResourceModuleHandler implements CoreCourseModuleHandler { constructor(protected resourceProvider: AddonModResourceProvider, private courseProvider: CoreCourseProvider, protected mimetypeUtils: CoreMimetypeUtilsProvider, private resourceHelper: AddonModResourceHelperProvider, protected prefetchDelegate: CoreCourseModulePrefetchDelegate, protected textUtils: CoreTextUtilsProvider, - protected translate: TranslateService) { + protected translate: TranslateService, protected timeUtils: CoreTimeUtilsProvider) { } /** @@ -185,18 +185,18 @@ export class AddonModResourceModuleHandler implements CoreCourseModuleHandler { if (options.showdate) { if (options.filedetails && options.filedetails.modifieddate) { extra.push(this.translate.instant('addon.mod_resource.modifieddate', - {$a: moment(options.filedetails.modifieddate * 1000).format('LLL')})); + {$a: this.timeUtils.userDate(options.filedetails.modifieddate * 1000, 'core.strftimedatetimeshort') })); } else if (options.filedetails && options.filedetails.uploadeddate) { extra.push(this.translate.instant('addon.mod_resource.uploadeddate', - {$a: moment(options.filedetails.uploadeddate * 1000).format('LLL')})); + {$a: this.timeUtils.userDate(options.filedetails.uploadeddate * 1000, 'core.strftimedatetimeshort') })); } else if (file.timemodified > file.timecreated + CoreConstants.SECONDS_MINUTE * 5) { /* Modified date may be up to several minutes later than uploaded date just because teacher did not submit the form promptly. Give teacher up to 5 minutes to do it. */ extra.push(this.translate.instant('addon.mod_resource.modifieddate', - {$a: moment(file.timemodified * 1000).format('LLL')})); + {$a: this.timeUtils.userDate(file.timemodified * 1000, 'core.strftimedatetimeshort') })); } else { extra.push(this.translate.instant('addon.mod_resource.uploadeddate', - {$a: moment(file.timecreated * 1000).format('LLL')})); + {$a: this.timeUtils.userDate(file.timecreated * 1000, 'core.strftimedatetimeshort') })); } } } diff --git a/src/addon/mod/scorm/providers/scorm-sync.ts b/src/addon/mod/scorm/providers/scorm-sync.ts index ae6281365..9a5d06ae7 100644 --- a/src/addon/mod/scorm/providers/scorm-sync.ts +++ b/src/addon/mod/scorm/providers/scorm-sync.ts @@ -20,6 +20,7 @@ import { CoreLoggerProvider } from '@providers/logger'; import { CoreSitesProvider } from '@providers/sites'; import { CoreSyncProvider } from '@providers/sync'; import { CoreTextUtilsProvider } from '@providers/utils/text'; +import { CoreTimeUtilsProvider } from '@providers/utils/time'; import { CoreUtilsProvider } from '@providers/utils/utils'; import { CoreCourseProvider } from '@core/course/providers/course'; import { CoreSyncBaseProvider } from '@classes/base-sync'; @@ -62,11 +63,12 @@ export class AddonModScormSyncProvider extends CoreSyncBaseProvider { constructor(loggerProvider: CoreLoggerProvider, sitesProvider: CoreSitesProvider, appProvider: CoreAppProvider, syncProvider: CoreSyncProvider, textUtils: CoreTextUtilsProvider, translate: TranslateService, - courseProvider: CoreCourseProvider, private eventsProvider: CoreEventsProvider, + courseProvider: CoreCourseProvider, private eventsProvider: CoreEventsProvider, timeUtils: CoreTimeUtilsProvider, private scormProvider: AddonModScormProvider, private scormOfflineProvider: AddonModScormOfflineProvider, private prefetchHandler: AddonModScormPrefetchHandler, private utils: CoreUtilsProvider) { - super('AddonModScormSyncProvider', loggerProvider, sitesProvider, appProvider, syncProvider, textUtils, translate); + super('AddonModScormSyncProvider', loggerProvider, sitesProvider, appProvider, syncProvider, textUtils, translate, + timeUtils); this.componentTranslate = courseProvider.translateModuleName('scorm'); } diff --git a/src/addon/mod/survey/providers/sync.ts b/src/addon/mod/survey/providers/sync.ts index ac3601d15..084e05eec 100644 --- a/src/addon/mod/survey/providers/sync.ts +++ b/src/addon/mod/survey/providers/sync.ts @@ -19,6 +19,7 @@ import { CoreSyncBaseProvider } from '@classes/base-sync'; import { CoreAppProvider } from '@providers/app'; import { CoreUtilsProvider } from '@providers/utils/utils'; import { CoreTextUtilsProvider } from '@providers/utils/text'; +import { CoreTimeUtilsProvider } from '@providers/utils/time'; import { AddonModSurveyOfflineProvider } from './offline'; import { AddonModSurveyProvider } from './survey'; import { CoreEventsProvider } from '@providers/events'; @@ -39,9 +40,10 @@ export class AddonModSurveySyncProvider extends CoreSyncBaseProvider { syncProvider: CoreSyncProvider, textUtils: CoreTextUtilsProvider, translate: TranslateService, courseProvider: CoreCourseProvider, private surveyOffline: AddonModSurveyOfflineProvider, private eventsProvider: CoreEventsProvider, private surveyProvider: AddonModSurveyProvider, - private utils: CoreUtilsProvider) { + private utils: CoreUtilsProvider, timeUtils: CoreTimeUtilsProvider) { - super('AddonModSurveySyncProvider', loggerProvider, sitesProvider, appProvider, syncProvider, textUtils, translate); + super('AddonModSurveySyncProvider', loggerProvider, sitesProvider, appProvider, syncProvider, textUtils, translate, + timeUtils); this.componentTranslate = courseProvider.translateModuleName('survey'); } diff --git a/src/addon/mod/wiki/providers/wiki-sync.ts b/src/addon/mod/wiki/providers/wiki-sync.ts index a042a04c9..5a2bdc441 100644 --- a/src/addon/mod/wiki/providers/wiki-sync.ts +++ b/src/addon/mod/wiki/providers/wiki-sync.ts @@ -21,6 +21,7 @@ import { CoreLoggerProvider } from '@providers/logger'; import { CoreSitesProvider } from '@providers/sites'; import { CoreSyncProvider } from '@providers/sync'; import { CoreTextUtilsProvider } from '@providers/utils/text'; +import { CoreTimeUtilsProvider } from '@providers/utils/time'; import { CoreUtilsProvider } from '@providers/utils/utils'; import { CoreCourseProvider } from '@core/course/providers/course'; import { CoreSyncBaseProvider } from '@classes/base-sync'; @@ -103,9 +104,10 @@ export class AddonModWikiSyncProvider extends CoreSyncBaseProvider { syncProvider: CoreSyncProvider, textUtils: CoreTextUtilsProvider, translate: TranslateService, courseProvider: CoreCourseProvider, private eventsProvider: CoreEventsProvider, private wikiProvider: AddonModWikiProvider, private wikiOfflineProvider: AddonModWikiOfflineProvider, - private utils: CoreUtilsProvider, private groupsProvider: CoreGroupsProvider) { + private utils: CoreUtilsProvider, private groupsProvider: CoreGroupsProvider, timeUtils: CoreTimeUtilsProvider) { - super('AddonModWikiSyncProvider', loggerProvider, sitesProvider, appProvider, syncProvider, textUtils, translate); + super('AddonModWikiSyncProvider', loggerProvider, sitesProvider, appProvider, syncProvider, textUtils, translate, + timeUtils); this.componentTranslate = courseProvider.translateModuleName('wiki'); } diff --git a/src/addon/mod/workshop/providers/sync.ts b/src/addon/mod/workshop/providers/sync.ts index e0f37b92c..f6693960f 100644 --- a/src/addon/mod/workshop/providers/sync.ts +++ b/src/addon/mod/workshop/providers/sync.ts @@ -22,6 +22,7 @@ import { CoreEventsProvider } from '@providers/events'; import { CoreSitesProvider } from '@providers/sites'; import { CoreSyncProvider } from '@providers/sync'; import { CoreTextUtilsProvider } from '@providers/utils/text'; +import { CoreTimeUtilsProvider } from '@providers/utils/time'; import { CoreUtilsProvider } from '@providers/utils/utils'; import { AddonModWorkshopProvider } from './workshop'; import { AddonModWorkshopHelperProvider } from './helper'; @@ -46,12 +47,14 @@ export class AddonModWorkshopSyncProvider extends CoreSyncBaseProvider { sitesProvider: CoreSitesProvider, syncProvider: CoreSyncProvider, textUtils: CoreTextUtilsProvider, + timeUtils: CoreTimeUtilsProvider, private utils: CoreUtilsProvider, private workshopProvider: AddonModWorkshopProvider, private workshopHelper: AddonModWorkshopHelperProvider, private workshopOffline: AddonModWorkshopOfflineProvider) { - super('AddonModWorkshopSyncProvider', loggerProvider, sitesProvider, appProvider, syncProvider, textUtils, translate); + super('AddonModWorkshopSyncProvider', loggerProvider, sitesProvider, appProvider, syncProvider, textUtils, translate, + timeUtils); this.componentTranslate = courseProvider.translateModuleName('workshop'); } diff --git a/src/addon/notes/providers/notes-sync.ts b/src/addon/notes/providers/notes-sync.ts index 059d61530..e02baf438 100644 --- a/src/addon/notes/providers/notes-sync.ts +++ b/src/addon/notes/providers/notes-sync.ts @@ -22,6 +22,7 @@ import { AddonNotesProvider } from './notes'; import { CoreCoursesProvider } from '@core/courses/providers/courses'; import { CoreEventsProvider } from '@providers/events'; import { CoreTextUtilsProvider } from '@providers/utils/text'; +import { CoreTimeUtilsProvider } from '@providers/utils/time'; import { CoreUtilsProvider } from '@providers/utils/utils'; import { TranslateService } from '@ngx-translate/core'; import { CoreSyncProvider } from '@providers/sync'; @@ -38,9 +39,9 @@ export class AddonNotesSyncProvider extends CoreSyncBaseProvider { syncProvider: CoreSyncProvider, textUtils: CoreTextUtilsProvider, translate: TranslateService, private notesOffline: AddonNotesOfflineProvider, private utils: CoreUtilsProvider, private eventsProvider: CoreEventsProvider, private notesProvider: AddonNotesProvider, - private coursesProvider: CoreCoursesProvider) { + private coursesProvider: CoreCoursesProvider, timeUtils: CoreTimeUtilsProvider) { - super('AddonNotesSync', loggerProvider, sitesProvider, appProvider, syncProvider, textUtils, translate); + super('AddonNotesSync', loggerProvider, sitesProvider, appProvider, syncProvider, textUtils, translate, timeUtils); } /** diff --git a/src/addon/userprofilefield/datetime/component/addon-user-profile-field-datetime.html b/src/addon/userprofilefield/datetime/component/addon-user-profile-field-datetime.html index 34423ce92..a3d9a57f2 100644 --- a/src/addon/userprofilefield/datetime/component/addon-user-profile-field-datetime.html +++ b/src/addon/userprofilefield/datetime/component/addon-user-profile-field-datetime.html @@ -1,7 +1,7 @@

{{ field.name }}

-

{{ field.value * 1000 | coreFormatDate:"dfmediumdate"}}

+

{{ field.value * 1000 | coreFormatDate }}

diff --git a/src/assets/lang/en.json b/src/assets/lang/en.json index fe2a2cea1..2b26aa66c 100644 --- a/src/assets/lang/en.json +++ b/src/assets/lang/en.json @@ -1655,6 +1655,21 @@ "core.sorry": "Sorry...", "core.sortby": "Sort by", "core.start": "Start", + "core.strftimedate": "%d %B %Y", + "core.strftimedatefullshort": "%d/%m/%y", + "core.strftimedateshort": "%d %B", + "core.strftimedatetime": "%d %B %Y, %I:%M %p", + "core.strftimedatetimeshort": "%d/%m/%y, %H:%M", + "core.strftimedaydate": "%A, %d %B %Y", + "core.strftimedaydatetime": "%A, %d %B %Y, %I:%M %p", + "core.strftimedayshort": "%A, %d %B", + "core.strftimedaytime": "%a, %H:%M", + "core.strftimemonthyear": "%B %Y", + "core.strftimerecent": "%d %b, %H:%M", + "core.strftimerecentfull": "%a, %d %b %Y, %I:%M %p", + "core.strftimetime": "%I:%M %p", + "core.strftimetime12": "%I:%M %p", + "core.strftimetime24": "%H:%M", "core.submit": "Submit", "core.success": "Success", "core.tablet": "Tablet", diff --git a/src/classes/base-sync.ts b/src/classes/base-sync.ts index d9fc0d477..2d1106973 100644 --- a/src/classes/base-sync.ts +++ b/src/classes/base-sync.ts @@ -18,7 +18,7 @@ import { CoreSyncProvider } from '@providers/sync'; import { CoreLoggerProvider } from '@providers/logger'; import { CoreAppProvider } from '@providers/app'; import { CoreTextUtilsProvider } from '@providers/utils/text'; -import * as moment from 'moment'; +import { CoreTimeUtilsProvider } from '@providers/utils/time'; /** * Base class to create sync providers. It provides some common functions. @@ -51,7 +51,8 @@ export class CoreSyncBaseProvider { constructor(component: string, loggerProvider: CoreLoggerProvider, protected sitesProvider: CoreSitesProvider, protected appProvider: CoreAppProvider, protected syncProvider: CoreSyncProvider, - protected textUtils: CoreTextUtilsProvider, protected translate: TranslateService) { + protected textUtils: CoreTextUtilsProvider, protected translate: TranslateService, + protected timeUtils: CoreTimeUtilsProvider) { this.logger = loggerProvider.getInstance(component); this.component = component; @@ -122,7 +123,7 @@ export class CoreSyncBaseProvider { if (!timestamp) { return this.translate.instant('core.never'); } else { - return moment(timestamp).format('LLL'); + return this.timeUtils.userDate(timestamp); } } diff --git a/src/components/file/core-file.html b/src/components/file/core-file.html index b8d89f5a2..1ae020dfa 100644 --- a/src/components/file/core-file.html +++ b/src/components/file/core-file.html @@ -2,7 +2,7 @@

{{fileName}}

{{ fileSizeReadable }}

-

{{ timemodified * 1000 | coreFormatDate:"dfmediumdate" }}

+

{{ timemodified * 1000 | coreFormatDate }}