From 30a7bca0eff5df906f234f9ef45f1a218170deda Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Tue, 29 Nov 2022 11:56:12 +0100 Subject: [PATCH] UserController should use `getLocalDate` from dateHelper (#13469) * Use `getLocalDate` from dateHelper * Remove duplicate import * Keep function getLocalDate but use dateHelper * Mark function as deprecated --- .../src/views/users/user.controller.js | 33 ++++++++----------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/users/user.controller.js b/src/Umbraco.Web.UI.Client/src/views/users/user.controller.js index f9d48d95e9..1df0827ace 100644 --- a/src/Umbraco.Web.UI.Client/src/views/users/user.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/users/user.controller.js @@ -109,22 +109,15 @@ }); }); } - + + /** + * @ngdoc function + * @function + * + * @deprecated + */ function getLocalDate(date, culture, format) { - if (date) { - var dateVal; - var serverOffset = Umbraco.Sys.ServerVariables.application.serverTimeOffset; - var localOffset = new Date().getTimezoneOffset(); - var serverTimeNeedsOffsetting = (-serverOffset !== localOffset); - - if (serverTimeNeedsOffsetting) { - dateVal = dateHelper.convertToLocalMomentTime(date, serverOffset); - } else { - dateVal = moment(date, "YYYY-MM-DD HH:mm:ss"); - } - - return dateVal.locale(culture).format(format); - } + return dateHelper.getLocaleDate(date, culture, format); } function toggleChangePassword() { @@ -571,11 +564,11 @@ userService.getCurrentUser().then(function (currentUser) { currentLoggedInUser = currentUser; - user.formattedLastLogin = getLocalDate(user.lastLoginDate, currentUser.locale, "LLL"); - user.formattedLastLockoutDate = getLocalDate(user.lastLockoutDate, currentUser.locale, "LLL"); - user.formattedCreateDate = getLocalDate(user.createDate, currentUser.locale, "LLL"); - user.formattedUpdateDate = getLocalDate(user.updateDate, currentUser.locale, "LLL"); - user.formattedLastPasswordChangeDate = getLocalDate(user.lastPasswordChangeDate, currentUser.locale, "LLL"); + user.formattedLastLogin = dateHelper.getLocalDate(user.lastLoginDate, currentUser.locale, "LLL"); + user.formattedLastLockoutDate = dateHelper.getLocalDate(user.lastLockoutDate, currentUser.locale, "LLL"); + user.formattedCreateDate = dateHelper.getLocalDate(user.createDate, currentUser.locale, "LLL"); + user.formattedUpdateDate = dateHelper.getLocalDate(user.updateDate, currentUser.locale, "LLL"); + user.formattedLastPasswordChangeDate = dateHelper.getLocalDate(user.lastPasswordChangeDate, currentUser.locale, "LLL"); }); }