From f4bb6b4aa9bc6157674e0d381ab2c8ab74a07279 Mon Sep 17 00:00:00 2001 From: Vladimir Sharanin Date: Thu, 30 Sep 2021 12:24:49 +0300 Subject: [PATCH] fixes Humanizr#898 Added DateToOrdinalWordsTests for Latvian language --- .../Humanizer.Tests.Shared.projitems | 1 + .../Localisation/lv/DateToOrdinalWordsTests.cs | 15 +++++++++++++++ .../LatvianNumberToWordsConverter.cs | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 src/Humanizer.Tests.Shared/Localisation/lv/DateToOrdinalWordsTests.cs diff --git a/src/Humanizer.Tests.Shared/Humanizer.Tests.Shared.projitems b/src/Humanizer.Tests.Shared/Humanizer.Tests.Shared.projitems index ee024b40e..a1913997d 100644 --- a/src/Humanizer.Tests.Shared/Humanizer.Tests.Shared.projitems +++ b/src/Humanizer.Tests.Shared/Humanizer.Tests.Shared.projitems @@ -107,6 +107,7 @@ + diff --git a/src/Humanizer.Tests.Shared/Localisation/lv/DateToOrdinalWordsTests.cs b/src/Humanizer.Tests.Shared/Localisation/lv/DateToOrdinalWordsTests.cs new file mode 100644 index 000000000..f18817ad6 --- /dev/null +++ b/src/Humanizer.Tests.Shared/Localisation/lv/DateToOrdinalWordsTests.cs @@ -0,0 +1,15 @@ +using System; +using Xunit; + +namespace Humanizer.Tests.Localisation.lv +{ + [UseCulture("lv")] + public class DateToOrdinalWordsTests + { + [Fact] + public void OrdinalizeString() + { + Assert.Equal("1 janvāris 2015", new DateTime(2015, 1, 1).ToOrdinalWords()); + } + } +} diff --git a/src/Humanizer/Localisation/NumberToWords/LatvianNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/LatvianNumberToWordsConverter.cs index 5bfb67294..ab5e579cc 100644 --- a/src/Humanizer/Localisation/NumberToWords/LatvianNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/LatvianNumberToWordsConverter.cs @@ -10,7 +10,7 @@ internal class LatvianNumberToWordsConverter : GenderedNumberToWordsConverter private static readonly string[] HundredsMap = { "nulle", "simt", "divsimt", "trīssimt", "četrsimt", "piecsimt", "sešsimt", "septiņsimt", "astoņsimt", "deviņsimt" }; private static readonly string[] UnitsOrdinal = { string.Empty, "pirm", "otr", "treš", "ceturt", "piekt", "sest", "septīt", "astot", "devīt", "desmit", "vienpadsmit", "divpadsmit", "trīspadsmit", "četrpadsmit", "piecpadsmit", "sešpadsmit", "septiņpadsmit", "astoņpadsmit", "deviņpadsmit", "divdesmit" }; - public override string Convert(long input, GrammaticalGender gender) + public override string Convert(long input, GrammaticalGender gender, bool addAnd = true) { if (input > int.MaxValue || input < int.MinValue) {