Skip to content

Commit

Permalink
fix Bug 65479
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelbannov committed Dec 12, 2023
1 parent 7b86b3f commit 5dbccca
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 28 deletions.
52 changes: 52 additions & 0 deletions common/ASC.Core.Common/Core/ArabicNumeralHelper.cs
Original file line number Diff line number Diff line change
@@ -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');

}
}
29 changes: 2 additions & 27 deletions products/ASC.Files/Core/Core/Entries/FileEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -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; }
Expand Down
7 changes: 6 additions & 1 deletion web/ASC.Web.Core/Notify/StudioWhatsNewNotify.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}

Expand Down

0 comments on commit 5dbccca

Please sign in to comment.