From 9ed2e48ff43e6ec3c53781905c7965f95861a19f Mon Sep 17 00:00:00 2001 From: Ethan Nagano <50598649+nagolucky18@users.noreply.github.com> Date: Mon, 12 Feb 2024 14:41:20 -0800 Subject: [PATCH] 15209 media picker shows incorrect date (#15414) * Trim update date to exclude Z character. When picking media, the items from an SQL database contain an update date that is formated in UTC-0 time by way of a Z character at the end of the string. Removing this string will result in the update date always displaying local time as expected. Issue: 15209 * Use dateHelper instead of slicing Z from date string. For most front end date formatting, dateHelper is used to get the local date. The dateHelper is now passed in to the media picker controller and used to format the date. --- .../mediapicker/mediapicker.controller.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/mediapicker/mediapicker.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/mediapicker/mediapicker.controller.js index a6e10f8e8f..ce6a09fa3f 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/mediapicker/mediapicker.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/mediapicker/mediapicker.controller.js @@ -1,7 +1,7 @@ //used for the media picker dialog angular.module("umbraco") .controller("Umbraco.Editors.MediaPickerController", - function ($scope, $timeout, mediaResource, entityResource, userService, mediaHelper, mediaTypeHelper, eventsService, treeService, localStorageService, localizationService, editorService, umbSessionStorage, notificationsService, clipboardService) { + function ($scope, $timeout, mediaResource, entityResource, userService, mediaHelper, mediaTypeHelper, eventsService, treeService, localStorageService, localizationService, dateHelper, editorService, umbSessionStorage, notificationsService, clipboardService) { var vm = this; @@ -575,9 +575,12 @@ angular.module("umbraco") if (item.metaData.MediaPath !== null) { item.thumbnail = mediaHelper.resolveFileFromEntity(item, true); item.image = mediaHelper.resolveFileFromEntity(item, false); - } - if (item.metaData.UpdateDate !== null) { - item.updateDate = item.metaData.UpdateDate; + } + if (item.metaData.UpdateDate !== null) { + userService.getCurrentUser().then(currentUser => { + item.updateDate = dateHelper.getLocalDate(item.metaData.UpdateDate, currentUser.locale, "LLL"); + }); + } }