From 5dbccca29b9f70d0492482841597f526fe645ba4 Mon Sep 17 00:00:00 2001 From: pavelbannov Date: Tue, 12 Dec 2023 19:59:48 +0300 Subject: [PATCH] fix Bug 65479 --- .../Core/ArabicNumeralHelper.cs | 52 +++++++++++++++++++ .../ASC.Files/Core/Core/Entries/FileEntry.cs | 29 +---------- .../Notify/StudioWhatsNewNotify.cs | 7 ++- 3 files changed, 60 insertions(+), 28 deletions(-) create mode 100644 common/ASC.Core.Common/Core/ArabicNumeralHelper.cs diff --git a/common/ASC.Core.Common/Core/ArabicNumeralHelper.cs b/common/ASC.Core.Common/Core/ArabicNumeralHelper.cs new file mode 100644 index 00000000000..2f04b5ed099 --- /dev/null +++ b/common/ASC.Core.Common/Core/ArabicNumeralHelper.cs @@ -0,0 +1,52 @@ +// (c) Copyright Ascensio System SIA 2010-2023 +// +// This program is a free software product. +// You can redistribute it and/or modify it under the terms +// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software +// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended +// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of +// any third-party rights. +// +// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty +// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see +// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html +// +// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021. +// +// The interactive user interfaces in modified source and object code versions of the Program must +// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3. +// +// Pursuant to Section 7(b) of the License you must retain the original Product logo when +// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under +// trademark law for use of our trademarks. +// +// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing +// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 +// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + +namespace ASC.Core.Common; + +public static class ArabicNumeralHelper +{ + public static string ConvertNumerals(this DateTime input, string format) + { + if (!new[] { "ar-lb", "ar-SA" }.Contains(Thread.CurrentThread.CurrentCulture.Name)) + { + return input.ToString(format, CultureInfo.InvariantCulture); + } + + var result = input.ToString(format, new CultureInfo("ar")); + return result + .Replace('0', '\u06f0') + .Replace('1', '\u06f1') + .Replace('2', '\u06f2') + .Replace('3', '\u06f3') + .Replace('4', '\u06f4') + .Replace('5', '\u06f5') + .Replace('6', '\u06f6') + .Replace('7', '\u06f7') + .Replace('8', '\u06f8') + .Replace('9', '\u06f9'); + + } +} \ No newline at end of file diff --git a/products/ASC.Files/Core/Core/Entries/FileEntry.cs b/products/ASC.Files/Core/Core/Entries/FileEntry.cs index b1fc424d231..2cc449157ac 100644 --- a/products/ASC.Files/Core/Core/Entries/FileEntry.cs +++ b/products/ASC.Files/Core/Core/Entries/FileEntry.cs @@ -64,10 +64,10 @@ public string ModifiedByString } [JsonIgnore] - public string CreateOnString => CreateOn.Equals(default) ? null : CreateOn.ConvertNumerals(); + public string CreateOnString => CreateOn.Equals(default) ? null : CreateOn.ConvertNumerals("g"); [JsonIgnore] - public string ModifiedOnString => ModifiedOn.Equals(default) ? null : ModifiedOn.ConvertNumerals(); + public string ModifiedOnString => ModifiedOn.Equals(default) ? null : ModifiedOn.ConvertNumerals("g"); public string Error { get; set; } public FileShare Access { get; set; } @@ -103,31 +103,6 @@ public object Clone() } } -static file class ArabicNumeralHelper -{ - public static string ConvertNumerals(this DateTime input) - { - if (!new[] { "ar-lb", "ar-SA" }.Contains(Thread.CurrentThread.CurrentCulture.Name)) - { - return input.ToString("g", CultureInfo.InvariantCulture); - } - - var result = input.ToString($"g", new CultureInfo("ar")); - return result - .Replace('0', '\u06f0') - .Replace('1', '\u06f1') - .Replace('2', '\u06f2') - .Replace('3', '\u06f3') - .Replace('4', '\u06f4') - .Replace('5', '\u06f5') - .Replace('6', '\u06f6') - .Replace('7', '\u06f7') - .Replace('8', '\u06f8') - .Replace('9', '\u06f9'); - - } -} - public interface IFileEntry { string UniqID { get; } diff --git a/web/ASC.Web.Core/Notify/StudioWhatsNewNotify.cs b/web/ASC.Web.Core/Notify/StudioWhatsNewNotify.cs index 12953b59793..06c8e0bb24c 100644 --- a/web/ASC.Web.Core/Notify/StudioWhatsNewNotify.cs +++ b/web/ASC.Web.Core/Notify/StudioWhatsNewNotify.cs @@ -365,7 +365,12 @@ private static string DateToString(DateTime d, WhatsNewType type, CultureInfo c) d = d.AddHours(-1); } - return d.ToString(c.TwoLetterISOLanguageName == "ru" ? "d MMMM" : "M", c); + if (c.TwoLetterISOLanguageName == "ru") + { + return d.ToString("d MMMM", c); + } + + return d.ConvertNumerals("M"); } }