diff --git a/.idea/.idea.IcgSoftware.RecurrenceRuleToText/.idea/.gitignore b/.idea/.idea.IcgSoftware.RecurrenceRuleToText/.idea/.gitignore new file mode 100644 index 0000000..9a7a9ed --- /dev/null +++ b/.idea/.idea.IcgSoftware.RecurrenceRuleToText/.idea/.gitignore @@ -0,0 +1,13 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Rider ignored files +/modules.xml +/.idea.IcgSoftware.RecurrenceRuleToText.iml +/projectSettingsUpdater.xml +/contentModel.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/.idea.IcgSoftware.RecurrenceRuleToText/.idea/.name b/.idea/.idea.IcgSoftware.RecurrenceRuleToText/.idea/.name new file mode 100644 index 0000000..9fb8ba0 --- /dev/null +++ b/.idea/.idea.IcgSoftware.RecurrenceRuleToText/.idea/.name @@ -0,0 +1 @@ +IcgSoftware.RecurrenceRuleToText \ No newline at end of file diff --git a/.idea/.idea.IcgSoftware.RecurrenceRuleToText/.idea/encodings.xml b/.idea/.idea.IcgSoftware.RecurrenceRuleToText/.idea/encodings.xml new file mode 100644 index 0000000..df87cf9 --- /dev/null +++ b/.idea/.idea.IcgSoftware.RecurrenceRuleToText/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/.idea.IcgSoftware.RecurrenceRuleToText/.idea/indexLayout.xml b/.idea/.idea.IcgSoftware.RecurrenceRuleToText/.idea/indexLayout.xml new file mode 100644 index 0000000..7b08163 --- /dev/null +++ b/.idea/.idea.IcgSoftware.RecurrenceRuleToText/.idea/indexLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/.idea.IcgSoftware.RecurrenceRuleToText/.idea/markdown.xml b/.idea/.idea.IcgSoftware.RecurrenceRuleToText/.idea/markdown.xml new file mode 100644 index 0000000..4e28a22 --- /dev/null +++ b/.idea/.idea.IcgSoftware.RecurrenceRuleToText/.idea/markdown.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/.idea.IcgSoftware.RecurrenceRuleToText/.idea/vcs.xml b/.idea/.idea.IcgSoftware.RecurrenceRuleToText/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/.idea.IcgSoftware.RecurrenceRuleToText/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/IcgSoftware.RecurrenceRuleToText.UnitTest/RRuleTextBuilderTestBase.cs b/IcgSoftware.RecurrenceRuleToText.UnitTest/RRuleTextBuilderTestBase.cs index bc5f4f8..c40d888 100644 --- a/IcgSoftware.RecurrenceRuleToText.UnitTest/RRuleTextBuilderTestBase.cs +++ b/IcgSoftware.RecurrenceRuleToText.UnitTest/RRuleTextBuilderTestBase.cs @@ -10,6 +10,8 @@ abstract public class RRuleTextBuilderTestBase abstract protected void ToTextTest(string rRuleString, string readableString); + abstract protected void ToTextTestWithShortWeekday(string rRuleString, string readableString); + protected class RRuleTextBuilderTestHelper { private RecurrencePattern recurrencePattern; @@ -28,15 +30,16 @@ public RRuleTextBuilderTestHelper(string rRuleString, string readableString) ReadableResult = recurrencePattern.ToText(); } - public RRuleTextBuilderTestHelper(string rRuleString, string readableString, string culture) + public RRuleTextBuilderTestHelper(string rRuleString, string readableString, string culture, DisplayOptions options = null) { - + options = options ?? new DisplayOptions(); + RRuleString = rRuleString; ReadableString = readableString; string rRuleStringC = RRuleTextBuilder.GetRRuleStringCorrection(rRuleString); recurrencePattern = new RecurrencePattern(rRuleStringC); RecreatedRRuleString = recurrencePattern.ToString(); - ReadableResult = recurrencePattern.ToText(new CultureInfo(culture)); + ReadableResult = recurrencePattern.ToText(new CultureInfo(culture), options); } public bool Result { get => ReadableString == ReadableResult; } diff --git a/IcgSoftware.RecurrenceRuleToText.UnitTest/RRuleTextBuilderTestDe.cs b/IcgSoftware.RecurrenceRuleToText.UnitTest/RRuleTextBuilderTestDe.cs index a77f778..27ad0c5 100644 --- a/IcgSoftware.RecurrenceRuleToText.UnitTest/RRuleTextBuilderTestDe.cs +++ b/IcgSoftware.RecurrenceRuleToText.UnitTest/RRuleTextBuilderTestDe.cs @@ -18,6 +18,13 @@ protected override void ToTextTest(string rRuleString, string readableString) Assert.IsTrue(rRuleTextBuilderTest.Result, rRuleTextBuilderTest.ResultMessage); } + protected override void ToTextTestWithShortWeekday(string rRuleString, string readableString) + { + Debug.WriteLine("DE: " + readableString); + var rRuleTextBuilderTest = new RRuleTextBuilderTestHelper(rRuleString, readableString, "de", new DisplayOptions(){ShortWeekdays = true}); + Assert.IsTrue(rRuleTextBuilderTest.Result, rRuleTextBuilderTest.ResultMessage); + } + [TestMethod] public void LastNumeral() { @@ -25,6 +32,11 @@ public void LastNumeral() ToTextTest("RRULE:FREQ=MONTHLY;BYDAY=-2MO", "monatlich am vorletzten Montag"); ToTextTest("RRULE:FREQ=MONTHLY;BYDAY=-3FR", "monatlich am drittletzten Freitag"); ToTextTest("RRULE:FREQ=MONTHLY;BYDAY=-4SU", "monatlich am viertletzten Sonntag"); + + ToTextTestWithShortWeekday("RRULE:FREQ=MONTHLY;BYDAY=-1MO", "monatlich am letzten Mo"); + ToTextTestWithShortWeekday("RRULE:FREQ=MONTHLY;BYDAY=-2MO", "monatlich am vorletzten Mo"); + ToTextTestWithShortWeekday("RRULE:FREQ=MONTHLY;BYDAY=-3FR", "monatlich am drittletzten Fr"); + ToTextTestWithShortWeekday("RRULE:FREQ=MONTHLY;BYDAY=-4SU", "monatlich am viertletzten So"); } [TestMethod] @@ -44,7 +56,7 @@ public void JavaRruleParser() ToTextTest("FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,TU", "wöchentlich am Montag, Dienstag"); ToTextTest("FREQ=WEEKLY;INTERVAL=2;BYDAY=MO,TU", "alle 2 Wochen am Montag, Dienstag"); - ToTextTest("FREQ=WEEKLY;INTERVAL=2;BYDAY=MO,TU,WE,SA", "alle 2 Wochen am Montag, Dienstag, Mittwoch, Sonnabend"); + ToTextTest("FREQ=WEEKLY;INTERVAL=2;BYDAY=MO,TU,WE,SA", "alle 2 Wochen am Montag, Dienstag, Mittwoch, Samstag"); ToTextTest("FREQ=MONTHLY;INTERVAL=1;BYMONTHDAY=5", "monatlich am 5."); ToTextTest("FREQ=MONTHLY;INTERVAL=1;BYMONTHDAY=15", "monatlich am 15."); @@ -52,7 +64,11 @@ public void JavaRruleParser() ToTextTest("FREQ=MONTHLY;INTERVAL=2;BYDAY=MO;BYSETPOS=-1", "alle 2 Monate am letzten Montag"); ToTextTest("FREQ=MONTHLY;INTERVAL=2;BYDAY=MO;BYSETPOS=1", "alle 2 Monate am ersten Montag"); - ToTextTest("FREQ=MONTHLY;INTERVAL=2;BYDAY=SA;BYSETPOS=3", "alle 2 Monate am dritten Sonnabend"); + ToTextTest("FREQ=MONTHLY;INTERVAL=2;BYDAY=SA;BYSETPOS=3", "alle 2 Monate am dritten Samstag"); + + ToTextTestWithShortWeekday("FREQ=MONTHLY;INTERVAL=2;BYDAY=MO;BYSETPOS=-1", "alle 2 Monate am letzten Mo"); + ToTextTestWithShortWeekday("FREQ=MONTHLY;INTERVAL=2;BYDAY=MO;BYSETPOS=1", "alle 2 Monate am ersten Mo"); + ToTextTestWithShortWeekday("FREQ=MONTHLY;INTERVAL=2;BYDAY=SA;BYSETPOS=3", "alle 2 Monate am dritten Sa"); ToTextTest("FREQ=YEARLY;BYMONTH=1;BYMONTHDAY=1", "jährlich am 01. Januar"); ToTextTest("FREQ=YEARLY;BYMONTH=4;BYMONTHDAY=5", "jährlich am 05. April"); @@ -76,6 +92,7 @@ public void Custom() ToTextTest("FREQ=MONTHLY;INTERVAL=2;BYDAY=FR;BYSETPOS=2", "alle 2 Monate am zweiten Freitag"); ToTextTest("FREQ=MONTHLY;INTERVAL=2;BYDAY=FR;BYSETPOS=3", "alle 2 Monate am dritten Freitag"); ToTextTest("FREQ=MONTHLY;INTERVAL=2;BYDAY=FR;BYSETPOS=4", "alle 2 Monate am vierten Freitag"); + ToTextTestWithShortWeekday("FREQ=MONTHLY;INTERVAL=2;BYDAY=FR;BYSETPOS=4", "alle 2 Monate am vierten Fr"); ToTextTest("FREQ=YEARLY;INTERVAL=3;BYMONTH=3,4", "alle 3 Jahre im März und April"); } @@ -108,6 +125,49 @@ public void RruleJsDemoApp() ToTextTest("RRULE:FREQ=WEEKLY;INTERVAL=2;BYDAY=TU", "alle 2 Wochen am Dienstag"); } - + [TestMethod] + public void NumeralMonthlyDay() + { + ToTextTest("FREQ=MONTHLY;BYDAY=SU,MO,TU,WE,TH,FR,SA;BYSETPOS=1", "monatlich am ersten Tag"); + ToTextTest("FREQ=MONTHLY;BYDAY=SU,MO,TU,WE,TH,FR,SA;BYSETPOS=2", "monatlich am zweiten Tag"); + ToTextTest("FREQ=MONTHLY;BYDAY=SU,MO,TU,WE,TH,FR,SA;BYSETPOS=-1", "monatlich am letzten Tag"); + ToTextTest("FREQ=MONTHLY;INTERVAL=2;BYDAY=SU,MO,TU,WE,TH,FR,SA;BYSETPOS=-1", "alle 2 Monate am letzten Tag"); + } + + [TestMethod] + public void NumeralMonthlyWeekday() + { + ToTextTest("FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=1", "monatlich am ersten Wochentag"); + ToTextTest("FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=2", "monatlich am zweiten Wochentag"); + ToTextTest("FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-1", "monatlich am letzten Wochentag"); + ToTextTest("FREQ=MONTHLY;INTERVAL=2;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-1", "alle 2 Monate am letzten Wochentag"); + } + + [TestMethod] + public void NumeralMonthlyWeekendDay() + { + ToTextTest("FREQ=MONTHLY;BYDAY=SU,SA;BYSETPOS=1", "monatlich am ersten Wochenendtag"); + ToTextTest("FREQ=MONTHLY;BYDAY=SU,SA;BYSETPOS=2", "monatlich am zweiten Wochenendtag"); + ToTextTest("FREQ=MONTHLY;BYDAY=SU,SA;BYSETPOS=-1", "monatlich am letzten Wochenendtag"); + ToTextTest("FREQ=MONTHLY;INTERVAL=2;BYDAY=SU,SA;BYSETPOS=-1", "alle 2 Monate am letzten Wochenendtag"); + } + + [TestMethod] + public void YearlyDay() + { + ToTextTest("FREQ=YEARLY;BYDAY=SU,MO,TU,WE,TH,FR,SA;BYMONTH=1;BYSETPOS=1", "jährlich am ersten Tag im Januar"); + } + + [TestMethod] + public void YearlyWeekday() + { + ToTextTest("FREQ=YEARLY;BYDAY=MO,TU,WE,TH,FR;BYMONTH=1;BYSETPOS=1", "jährlich am ersten Wochentag im Januar"); + } + + [TestMethod] + public void YearlyWeekendDay() + { + ToTextTest("FREQ=YEARLY;BYDAY=SU,SA;BYMONTH=1;BYSETPOS=1", "jährlich am ersten Wochenendtag im Januar"); + } } } diff --git a/IcgSoftware.RecurrenceRuleToText.UnitTest/RRuleTextBuilderTestEn.cs b/IcgSoftware.RecurrenceRuleToText.UnitTest/RRuleTextBuilderTestEn.cs index 4f88773..591af41 100644 --- a/IcgSoftware.RecurrenceRuleToText.UnitTest/RRuleTextBuilderTestEn.cs +++ b/IcgSoftware.RecurrenceRuleToText.UnitTest/RRuleTextBuilderTestEn.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Diagnostics; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace IcgSoftware.RecurrenceRuleToText.UnitTest @@ -17,6 +12,13 @@ protected override void ToTextTest(string rRuleString, string readableString) var rRuleTextBuilderTest = new RRuleTextBuilderTestHelper(rRuleString, readableString, "en"); Assert.IsTrue(rRuleTextBuilderTest.Result, rRuleTextBuilderTest.ResultMessage); } + + protected override void ToTextTestWithShortWeekday(string rRuleString, string readableString) + { + Debug.WriteLine("EN: " + readableString); + var rRuleTextBuilderTest = new RRuleTextBuilderTestHelper(rRuleString, readableString, "en", new DisplayOptions(){ShortWeekdays = true}); + Assert.IsTrue(rRuleTextBuilderTest.Result, rRuleTextBuilderTest.ResultMessage); + } [TestMethod] public void LastNumeral() @@ -108,5 +110,22 @@ public void RruleJsDemoApp() ToTextTest("RRULE:FREQ=WEEKLY;INTERVAL=2;BYDAY=TU", "every 2 weeks on Tuesday"); } + [TestMethod] + public void YearlyDay() + { + ToTextTest("FREQ=YEARLY;BYDAY=SU,MO,TU,WE,TH,FR,SA;BYMONTH=1;BYSETPOS=1", "every year on first day of January"); + } + + [TestMethod] + public void YearlyWeekday() + { + ToTextTest("FREQ=YEARLY;BYDAY=MO,TU,WE,TH,FR;BYMONTH=1;BYSETPOS=1", "every year on first weekday of January"); + } + + [TestMethod] + public void YearlyWeekendDay() + { + ToTextTest("FREQ=YEARLY;BYDAY=SU,SA;BYMONTH=1;BYSETPOS=1", "every year on first weekend days of January"); + } } } diff --git a/IcgSoftware.RecurrenceRuleToText.UnitTest/RRuleTextBuilderTestEs.cs b/IcgSoftware.RecurrenceRuleToText.UnitTest/RRuleTextBuilderTestEs.cs index 146d8a2..e98d390 100644 --- a/IcgSoftware.RecurrenceRuleToText.UnitTest/RRuleTextBuilderTestEs.cs +++ b/IcgSoftware.RecurrenceRuleToText.UnitTest/RRuleTextBuilderTestEs.cs @@ -17,6 +17,13 @@ protected override void ToTextTest(string rRuleString, string readableString) var rRuleTextBuilderTest = new RRuleTextBuilderTestHelper(rRuleString, readableString, "es"); Assert.IsTrue(rRuleTextBuilderTest.Result, rRuleTextBuilderTest.ResultMessage); } + + protected override void ToTextTestWithShortWeekday(string rRuleString, string readableString) + { + Debug.WriteLine("ES: " + readableString); + var rRuleTextBuilderTest = new RRuleTextBuilderTestHelper(rRuleString, readableString, "es", new DisplayOptions(){ShortWeekdays = true}); + Assert.IsTrue(rRuleTextBuilderTest.Result, rRuleTextBuilderTest.ResultMessage); + } [TestMethod] public void LastNumeral() @@ -24,7 +31,7 @@ public void LastNumeral() ToTextTest("RRULE:FREQ=MONTHLY;BYDAY=-1MO", "cada mes el último lunes"); ToTextTest("RRULE:FREQ=MONTHLY;BYDAY=-2MO", "cada mes el penúltimo lunes"); ToTextTest("RRULE:FREQ=MONTHLY;BYDAY=-3FR", "cada mes el tercer último viernes"); - ToTextTest("RRULE:FREQ=MONTHLY;BYDAY=-4SU", "cada mes el cuarto último domingos"); + ToTextTest("RRULE:FREQ=MONTHLY;BYDAY=-4SU", "cada mes el cuarto último domingo"); } [TestMethod] @@ -44,7 +51,7 @@ public void JavaRruleParser() ToTextTest("FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,TU", "cada semana los lunes, martes"); ToTextTest("FREQ=WEEKLY;INTERVAL=2;BYDAY=MO,TU", "cada 2 semanas los lunes, martes"); - ToTextTest("FREQ=WEEKLY;INTERVAL=2;BYDAY=MO,TU,WE,SA", "cada 2 semanas los lunes, martes, miércoles, sábados"); + ToTextTest("FREQ=WEEKLY;INTERVAL=2;BYDAY=MO,TU,WE,SA", "cada 2 semanas los lunes, martes, miércoles, sábado"); ToTextTest("FREQ=MONTHLY;INTERVAL=1;BYMONTHDAY=5", "cada mes el 5º"); ToTextTest("FREQ=MONTHLY;INTERVAL=1;BYMONTHDAY=15", "cada mes el 15º"); @@ -52,12 +59,12 @@ public void JavaRruleParser() ToTextTest("FREQ=MONTHLY;INTERVAL=2;BYDAY=MO;BYSETPOS=-1", "cada 2 meses el último lunes"); ToTextTest("FREQ=MONTHLY;INTERVAL=2;BYDAY=MO;BYSETPOS=1", "cada 2 meses el primer lunes"); - ToTextTest("FREQ=MONTHLY;INTERVAL=2;BYDAY=SA;BYSETPOS=3", "cada 2 meses el tercer sábados"); + ToTextTest("FREQ=MONTHLY;INTERVAL=2;BYDAY=SA;BYSETPOS=3", "cada 2 meses el tercer sábado"); ToTextTest("FREQ=YEARLY;BYMONTH=1;BYMONTHDAY=1", "cada año el 1º de enero"); ToTextTest("FREQ=YEARLY;BYMONTH=4;BYMONTHDAY=5", "cada año el 5º de abril"); - ToTextTest("FREQ=YEARLY;BYDAY=SU;BYSETPOS=1;BYMONTH=1", "cada año el primer domingos de enero"); + ToTextTest("FREQ=YEARLY;BYDAY=SU;BYSETPOS=1;BYMONTH=1", "cada año el primer domingo de enero"); ToTextTest("FREQ=YEARLY;BYDAY=WE;BYSETPOS=-1;BYMONTH=4", "cada año el último miércoles de abril"); ToTextTest("FREQ=DAILY;INTERVAL=1;COUNT=2", "cada día un total de 2 veces"); @@ -71,7 +78,7 @@ public void Custom() { ToTextTest("FREQ=WEEKLY;COUNT=30;INTERVAL=1;WKST=MO;BYDAY=FR,TH,MO,TU,WE", "todos los días de la semana un total de 30 veces"); ToTextTest("FREQ=WEEKLY;COUNT=30;INTERVAL=1;WKST=MO;BYDAY=FR,TU,WE,TH", "cada semana los martes, miércoles, jueves, viernes un total de 30 veces"); - ToTextTest("FREQ=WEEKLY;COUNT=30;INTERVAL=1;WKST=SU;BYDAY=FR,TU,WE,TH,SU", "cada semana los domingos, martes, miércoles, jueves, viernes un total de 30 veces"); + ToTextTest("FREQ=WEEKLY;COUNT=30;INTERVAL=1;WKST=SU;BYDAY=FR,TU,WE,TH,SU", "cada semana los domingo, martes, miércoles, jueves, viernes un total de 30 veces"); ToTextTest("FREQ=MONTHLY;INTERVAL=2;BYDAY=FR;BYSETPOS=1", "cada 2 meses el primer viernes"); ToTextTest("FREQ=MONTHLY;INTERVAL=2;BYDAY=FR;BYSETPOS=2", "cada 2 meses el segundo viernes"); ToTextTest("FREQ=MONTHLY;INTERVAL=2;BYDAY=FR;BYSETPOS=3", "cada 2 meses el tercer viernes"); @@ -108,6 +115,22 @@ public void RruleJsDemoApp() ToTextTest("RRULE:FREQ=WEEKLY;INTERVAL=2;BYDAY=TU", "cada 2 semanas los martes"); } - + [TestMethod] + public void YearlyDay() + { + ToTextTest("FREQ=YEARLY;BYDAY=SU,MO,TU,WE,TH,FR,SA;BYMONTH=1;BYSETPOS=1", "cada año el primer día de enero"); + } + + [TestMethod] + public void YearlyWeekday() + { + ToTextTest("FREQ=YEARLY;BYDAY=MO,TU,WE,TH,FR;BYMONTH=1;BYSETPOS=1", "cada año el primer día laborable de enero"); + } + + [TestMethod] + public void YearlyWeekendDay() + { + ToTextTest("FREQ=YEARLY;BYDAY=SU,SA;BYMONTH=1;BYSETPOS=1", "cada año el primer día del fin de semana de enero"); + } } } diff --git a/IcgSoftware.RecurrenceRuleToText.UnitTest/RRuleTextBuilderTestFr.cs b/IcgSoftware.RecurrenceRuleToText.UnitTest/RRuleTextBuilderTestFr.cs index 1dc168b..bee218e 100644 --- a/IcgSoftware.RecurrenceRuleToText.UnitTest/RRuleTextBuilderTestFr.cs +++ b/IcgSoftware.RecurrenceRuleToText.UnitTest/RRuleTextBuilderTestFr.cs @@ -17,6 +17,13 @@ protected override void ToTextTest(string rRuleString, string readableString) var rRuleTextBuilderTest = new RRuleTextBuilderTestHelper(rRuleString, readableString, "fr"); Assert.IsTrue(rRuleTextBuilderTest.Result, rRuleTextBuilderTest.ResultMessage); } + + protected override void ToTextTestWithShortWeekday(string rRuleString, string readableString) + { + Debug.WriteLine("FR: " + readableString); + var rRuleTextBuilderTest = new RRuleTextBuilderTestHelper(rRuleString, readableString, "fr", new DisplayOptions(){ShortWeekdays = true}); + Assert.IsTrue(rRuleTextBuilderTest.Result, rRuleTextBuilderTest.ResultMessage); + } [TestMethod] public void LastNumeral() @@ -106,5 +113,22 @@ public void RruleJsDemoApp() ToTextTest("RRULE:FREQ=WEEKLY;INTERVAL=2;BYDAY=TU", "toutes les 2 semaines le mardi"); } + [TestMethod] + public void YearlyDay() + { + ToTextTest("FREQ=YEARLY;BYDAY=SU,MO,TU,WE,TH,FR,SA;BYMONTH=1;BYSETPOS=1", "tous les ans le premier jour de janvier"); + } + + [TestMethod] + public void YearlyWeekday() + { + ToTextTest("FREQ=YEARLY;BYDAY=MO,TU,WE,TH,FR;BYMONTH=1;BYSETPOS=1", "tous les ans le premier jour ouvrable de janvier"); + } + + [TestMethod] + public void YearlyWeekendDay() + { + ToTextTest("FREQ=YEARLY;BYDAY=SU,SA;BYMONTH=1;BYSETPOS=1", "tous les ans le premier jour du weekend de janvier"); + } } } diff --git a/IcgSoftware.RecurrenceRuleToText.UnitTest/RRuleTextBuilderTestIv.cs b/IcgSoftware.RecurrenceRuleToText.UnitTest/RRuleTextBuilderTestIv.cs index bca5c44..88eb718 100644 --- a/IcgSoftware.RecurrenceRuleToText.UnitTest/RRuleTextBuilderTestIv.cs +++ b/IcgSoftware.RecurrenceRuleToText.UnitTest/RRuleTextBuilderTestIv.cs @@ -18,6 +18,13 @@ protected override void ToTextTest(string rRuleString, string readableString) Assert.IsTrue(rRuleTextBuilderTest.Result, rRuleTextBuilderTest.ResultMessage); } + protected override void ToTextTestWithShortWeekday(string rRuleString, string readableString) + { + Debug.WriteLine("IV: " + readableString); + var rRuleTextBuilderTest = new RRuleTextBuilderTestHelper(rRuleString, readableString, "", new DisplayOptions(){ShortWeekdays = true}); + Assert.IsTrue(rRuleTextBuilderTest.Result, rRuleTextBuilderTest.ResultMessage); + } + [TestMethod] public void InvariantCulture() { diff --git a/IcgSoftware.RecurrenceRuleToText/DisplayOptions.cs b/IcgSoftware.RecurrenceRuleToText/DisplayOptions.cs new file mode 100644 index 0000000..7b17433 --- /dev/null +++ b/IcgSoftware.RecurrenceRuleToText/DisplayOptions.cs @@ -0,0 +1,7 @@ +namespace IcgSoftware.RecurrenceRuleToText +{ + public class DisplayOptions + { + public bool ShortWeekdays { get; set; } + } +} \ No newline at end of file diff --git a/IcgSoftware.RecurrenceRuleToText/IcgSoftware.RecurrenceRuleToText.csproj b/IcgSoftware.RecurrenceRuleToText/IcgSoftware.RecurrenceRuleToText.csproj index 3956c71..ec8ff54 100644 --- a/IcgSoftware.RecurrenceRuleToText/IcgSoftware.RecurrenceRuleToText.csproj +++ b/IcgSoftware.RecurrenceRuleToText/IcgSoftware.RecurrenceRuleToText.csproj @@ -7,11 +7,13 @@ IcgSoftware Human readable extension for iCal.NET RecurrencePattern https://github.com/rianjs/ical.net MIT - https://github.com/pt-icg/RecurrenceRuleToText - https://github.com/pt-icg/RecurrenceRuleToText + https://github.com/RECOMGmbH/RecurrenceRuleToText + https://github.com/RECOMGmbH/RecurrenceRuleToText icalendar ical ical.net recurrence rrule recurrence-rules human-readable multi-language-support ical-net-extension c# net csharp 1.0.2.0 1.0.2.0 + true + 1.0.2-recom diff --git a/IcgSoftware.RecurrenceRuleToText/Language.Designer.cs b/IcgSoftware.RecurrenceRuleToText/Language.Designer.cs index 7c338cd..dbdbac3 100644 --- a/IcgSoftware.RecurrenceRuleToText/Language.Designer.cs +++ b/IcgSoftware.RecurrenceRuleToText/Language.Designer.cs @@ -87,6 +87,15 @@ internal static string DailyEveryNDays { } } + /// + /// Looks up a localized string similar to day. + /// + internal static string Day { + get { + return ResourceManager.GetString("Day", resourceCulture); + } + } + /// /// Looks up a localized string similar to and. /// @@ -123,15 +132,6 @@ internal static string FourthLastNumeral { } } - /// - /// Looks up a localized string similar to Friday. - /// - internal static string Friday { - get { - return ResourceManager.GetString("Friday", resourceCulture); - } - } - /// /// Looks up a localized string similar to last. /// @@ -150,15 +150,6 @@ internal static string LastNumeral { } } - /// - /// Looks up a localized string similar to Monday. - /// - internal static string Monday { - get { - return ResourceManager.GetString("Monday", resourceCulture); - } - } - /// /// Looks up a localized string similar to and. /// @@ -249,15 +240,6 @@ internal static string PhraseStructure { } } - /// - /// Looks up a localized string similar to Saturday. - /// - internal static string Saturday { - get { - return ResourceManager.GetString("Saturday", resourceCulture); - } - } - /// /// Looks up a localized string similar to second. /// @@ -276,15 +258,6 @@ internal static string SecondLastNumeral { } } - /// - /// Looks up a localized string similar to Sunday. - /// - internal static string Sunday { - get { - return ResourceManager.GetString("Sunday", resourceCulture); - } - } - /// /// Looks up a localized string similar to third. /// @@ -303,24 +276,6 @@ internal static string ThirdLastNumeral { } } - /// - /// Looks up a localized string similar to Thursday. - /// - internal static string Thursday { - get { - return ResourceManager.GetString("Thursday", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Tuesday. - /// - internal static string Tuesday { - get { - return ResourceManager.GetString("Tuesday", resourceCulture); - } - } - /// /// Looks up a localized string similar to until {0}. /// @@ -340,11 +295,20 @@ internal static string UntilDateEndingDateFormat { } /// - /// Looks up a localized string similar to Wednesday. + /// Looks up a localized string similar to weekday. + /// + internal static string Weekday { + get { + return ResourceManager.GetString("Weekday", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to weekend days. /// - internal static string Wednesday { + internal static string WeekendDay { get { - return ResourceManager.GetString("Wednesday", resourceCulture); + return ResourceManager.GetString("WeekendDay", resourceCulture); } } diff --git a/IcgSoftware.RecurrenceRuleToText/Language.de.resx b/IcgSoftware.RecurrenceRuleToText/Language.de.resx index cc82fd0..5d6e8e4 100644 --- a/IcgSoftware.RecurrenceRuleToText/Language.de.resx +++ b/IcgSoftware.RecurrenceRuleToText/Language.de.resx @@ -170,27 +170,6 @@ dd. MMMM - - Montag - - - Dienstag - - - Mittwoch - - - Donnerstag - - - Freitag - - - Sonnabend - - - Sonntag - insgesamt {0} Mal @@ -254,4 +233,13 @@ im {0} + + Tag + + + Wochenendtag + + + Wochentag + \ No newline at end of file diff --git a/IcgSoftware.RecurrenceRuleToText/Language.es.Designer.cs b/IcgSoftware.RecurrenceRuleToText/Language.es.Designer.cs index 5f28270..114e721 100644 --- a/IcgSoftware.RecurrenceRuleToText/Language.es.Designer.cs +++ b/IcgSoftware.RecurrenceRuleToText/Language.es.Designer.cs @@ -1 +1,423 @@ - \ No newline at end of file +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace IcgSoftware.RecurrenceRuleToText { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Language_es { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Language_es() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("IcgSoftware.RecurrenceRuleToText.Language.es", typeof(Language_es).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to un total de {0} veces. + /// + internal static string CountEnding { + get { + return ResourceManager.GetString("CountEnding", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to cada día. + /// + internal static string Daily { + get { + return ResourceManager.GetString("Daily", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to cada {0} dias. + /// + internal static string DailyEveryNDays { + get { + return ResourceManager.GetString("DailyEveryNDays", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to día. + /// + internal static string Day { + get { + return ResourceManager.GetString("Day", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to y. + /// + internal static string DayChainLastSeparator { + get { + return ResourceManager.GetString("DayChainLastSeparator", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to primer. + /// + internal static string First { + get { + return ResourceManager.GetString("First", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to cuarto. + /// + internal static string Fourth { + get { + return ResourceManager.GetString("Fourth", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to el cuarto último {0}. + /// + internal static string FourthLastNumeral { + get { + return ResourceManager.GetString("FourthLastNumeral", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to último. + /// + internal static string Last { + get { + return ResourceManager.GetString("Last", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to el último {0}. + /// + internal static string LastNumeral { + get { + return ResourceManager.GetString("LastNumeral", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to y. + /// + internal static string MonthChainLastSeparator { + get { + return ResourceManager.GetString("MonthChainLastSeparator", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to cada mes. + /// + internal static string Monthly { + get { + return ResourceManager.GetString("Monthly", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to cada {0} meses. + /// + internal static string MonthlyEveryNMonths { + get { + return ResourceManager.GetString("MonthlyEveryNMonths", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to el {0}. + /// + internal static string MonthlyOnDay { + get { + return ResourceManager.GetString("MonthlyOnDay", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to los {0}. + /// + internal static string MonthlyOnDayPlural { + get { + return ResourceManager.GetString("MonthlyOnDayPlural", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to el {0}. + /// + internal static string MonthlyOnNumberedDay { + get { + return ResourceManager.GetString("MonthlyOnNumberedDay", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to el {0}. + /// + internal static string MonthlyOnWeekDay { + get { + return ResourceManager.GetString("MonthlyOnWeekDay", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0}. + /// + internal static string MonthlyOnWeekDayNumeral { + get { + return ResourceManager.GetString("MonthlyOnWeekDayNumeral", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to false. + /// + internal static string PhraseFirstCharToUpper { + get { + return ResourceManager.GetString("PhraseFirstCharToUpper", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} {1} {2}. + /// + internal static string PhraseStructure { + get { + return ResourceManager.GetString("PhraseStructure", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to segundo. + /// + internal static string Second { + get { + return ResourceManager.GetString("Second", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to el penúltimo {0}. + /// + internal static string SecondLastNumeral { + get { + return ResourceManager.GetString("SecondLastNumeral", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to tercer. + /// + internal static string Third { + get { + return ResourceManager.GetString("Third", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to el tercer último {0}. + /// + internal static string ThirdLastNumeral { + get { + return ResourceManager.GetString("ThirdLastNumeral", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to hasta el {0}. + /// + internal static string UntilDateEnding { + get { + return ResourceManager.GetString("UntilDateEnding", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to D. + /// + internal static string UntilDateEndingDateFormat { + get { + return ResourceManager.GetString("UntilDateEndingDateFormat", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to día laborable. + /// + internal static string Weekday { + get { + return ResourceManager.GetString("Weekday", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to día del fin de semana. + /// + internal static string WeekendDay { + get { + return ResourceManager.GetString("WeekendDay", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to cada semana. + /// + internal static string Weekly { + get { + return ResourceManager.GetString("Weekly", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to los {0}. + /// + internal static string WeeklyDays { + get { + return ResourceManager.GetString("WeeklyDays", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to cada día. + /// + internal static string WeeklyEveryDay { + get { + return ResourceManager.GetString("WeeklyEveryDay", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to cada {0} semanas. + /// + internal static string WeeklyEveryNWeeks { + get { + return ResourceManager.GetString("WeeklyEveryNWeeks", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to todos los días de la semana. + /// + internal static string WeeklyEveryWeekday { + get { + return ResourceManager.GetString("WeeklyEveryWeekday", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to cada año. + /// + internal static string Yearly { + get { + return ResourceManager.GetString("Yearly", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to cada {0} años. + /// + internal static string YearlyEveryNYears { + get { + return ResourceManager.GetString("YearlyEveryNYears", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to el {1} de {0}. + /// + internal static string YearlyOnDay { + get { + return ResourceManager.GetString("YearlyOnDay", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to MMMM. + /// + internal static string YearlyOnDayMonthPattern { + get { + return ResourceManager.GetString("YearlyOnDayMonthPattern", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to en {0}. + /// + internal static string YearlyOnMonth { + get { + return ResourceManager.GetString("YearlyOnMonth", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to el {0} {1} de {2}. + /// + internal static string YearlyOnNumbered { + get { + return ResourceManager.GetString("YearlyOnNumbered", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to MMMM. + /// + internal static string YearlyOnNumberedMonthFormat { + get { + return ResourceManager.GetString("YearlyOnNumberedMonthFormat", resourceCulture); + } + } + } +} diff --git a/IcgSoftware.RecurrenceRuleToText/Language.es.resx b/IcgSoftware.RecurrenceRuleToText/Language.es.resx index 5b00d8c..26b44db 100644 --- a/IcgSoftware.RecurrenceRuleToText/Language.es.resx +++ b/IcgSoftware.RecurrenceRuleToText/Language.es.resx @@ -166,27 +166,6 @@ MMMM - - lunes - - - martes - - - miércoles - - - jueves - - - viernes - - - sábados - - - domingos - un total de {0} veces @@ -251,4 +230,13 @@ en {0} + + día + + + día laborable + + + día del fin de semana + \ No newline at end of file diff --git a/IcgSoftware.RecurrenceRuleToText/Language.fr.Designer.cs b/IcgSoftware.RecurrenceRuleToText/Language.fr.Designer.cs index 5f28270..61f3f4b 100644 --- a/IcgSoftware.RecurrenceRuleToText/Language.fr.Designer.cs +++ b/IcgSoftware.RecurrenceRuleToText/Language.fr.Designer.cs @@ -1 +1,423 @@ - \ No newline at end of file +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace IcgSoftware.RecurrenceRuleToText { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Language_fr { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Language_fr() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("IcgSoftware.RecurrenceRuleToText.Language.fr", typeof(Language_fr).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to à {0} reprises. + /// + internal static string CountEnding { + get { + return ResourceManager.GetString("CountEnding", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to tous les jours. + /// + internal static string Daily { + get { + return ResourceManager.GetString("Daily", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to tous les {0} jours. + /// + internal static string DailyEveryNDays { + get { + return ResourceManager.GetString("DailyEveryNDays", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to jour. + /// + internal static string Day { + get { + return ResourceManager.GetString("Day", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to et. + /// + internal static string DayChainLastSeparator { + get { + return ResourceManager.GetString("DayChainLastSeparator", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to premier. + /// + internal static string First { + get { + return ResourceManager.GetString("First", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to quatrième. + /// + internal static string Fourth { + get { + return ResourceManager.GetString("Fourth", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to le quatrième {0} dernier. + /// + internal static string FourthLastNumeral { + get { + return ResourceManager.GetString("FourthLastNumeral", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to dernier. + /// + internal static string Last { + get { + return ResourceManager.GetString("Last", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to le dernier {0}. + /// + internal static string LastNumeral { + get { + return ResourceManager.GetString("LastNumeral", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to et. + /// + internal static string MonthChainLastSeparator { + get { + return ResourceManager.GetString("MonthChainLastSeparator", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to tous les mois. + /// + internal static string Monthly { + get { + return ResourceManager.GetString("Monthly", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to tous les {0} mois. + /// + internal static string MonthlyEveryNMonths { + get { + return ResourceManager.GetString("MonthlyEveryNMonths", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to le {0}. + /// + internal static string MonthlyOnDay { + get { + return ResourceManager.GetString("MonthlyOnDay", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to les {0}. + /// + internal static string MonthlyOnDayPlural { + get { + return ResourceManager.GetString("MonthlyOnDayPlural", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to le {0}. + /// + internal static string MonthlyOnNumberedDay { + get { + return ResourceManager.GetString("MonthlyOnNumberedDay", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to le {0}. + /// + internal static string MonthlyOnWeekDay { + get { + return ResourceManager.GetString("MonthlyOnWeekDay", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0}. + /// + internal static string MonthlyOnWeekDayNumeral { + get { + return ResourceManager.GetString("MonthlyOnWeekDayNumeral", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to false. + /// + internal static string PhraseFirstCharToUpper { + get { + return ResourceManager.GetString("PhraseFirstCharToUpper", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} {1} {2}. + /// + internal static string PhraseStructure { + get { + return ResourceManager.GetString("PhraseStructure", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to deuxième. + /// + internal static string Second { + get { + return ResourceManager.GetString("Second", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to l'avant-dernier {0}. + /// + internal static string SecondLastNumeral { + get { + return ResourceManager.GetString("SecondLastNumeral", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to troisième. + /// + internal static string Third { + get { + return ResourceManager.GetString("Third", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to le troisième {0} dernier. + /// + internal static string ThirdLastNumeral { + get { + return ResourceManager.GetString("ThirdLastNumeral", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to jusqu'au {0}. + /// + internal static string UntilDateEnding { + get { + return ResourceManager.GetString("UntilDateEnding", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to dd MMMM yyyy. + /// + internal static string UntilDateEndingDateFormat { + get { + return ResourceManager.GetString("UntilDateEndingDateFormat", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to jour ouvrable. + /// + internal static string Weekday { + get { + return ResourceManager.GetString("Weekday", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to jour du weekend. + /// + internal static string WeekendDay { + get { + return ResourceManager.GetString("WeekendDay", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to toutes les semaines. + /// + internal static string Weekly { + get { + return ResourceManager.GetString("Weekly", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to le {0}. + /// + internal static string WeeklyDays { + get { + return ResourceManager.GetString("WeeklyDays", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to tous les jours. + /// + internal static string WeeklyEveryDay { + get { + return ResourceManager.GetString("WeeklyEveryDay", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to toutes les {0} semaines. + /// + internal static string WeeklyEveryNWeeks { + get { + return ResourceManager.GetString("WeeklyEveryNWeeks", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to tous les jours. + /// + internal static string WeeklyEveryWeekday { + get { + return ResourceManager.GetString("WeeklyEveryWeekday", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to tous les ans. + /// + internal static string Yearly { + get { + return ResourceManager.GetString("Yearly", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to tous les {0} ans. + /// + internal static string YearlyEveryNYears { + get { + return ResourceManager.GetString("YearlyEveryNYears", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to le {1} {0}. + /// + internal static string YearlyOnDay { + get { + return ResourceManager.GetString("YearlyOnDay", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to MMMM. + /// + internal static string YearlyOnDayMonthPattern { + get { + return ResourceManager.GetString("YearlyOnDayMonthPattern", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to en {0}. + /// + internal static string YearlyOnMonth { + get { + return ResourceManager.GetString("YearlyOnMonth", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to le {0} {1} de {2}. + /// + internal static string YearlyOnNumbered { + get { + return ResourceManager.GetString("YearlyOnNumbered", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to MMMM. + /// + internal static string YearlyOnNumberedMonthFormat { + get { + return ResourceManager.GetString("YearlyOnNumberedMonthFormat", resourceCulture); + } + } + } +} diff --git a/IcgSoftware.RecurrenceRuleToText/Language.fr.resx b/IcgSoftware.RecurrenceRuleToText/Language.fr.resx index 8b36d49..1428268 100644 --- a/IcgSoftware.RecurrenceRuleToText/Language.fr.resx +++ b/IcgSoftware.RecurrenceRuleToText/Language.fr.resx @@ -168,27 +168,6 @@ MMMM - - lundi - - - mardi - - - mercredi - - - jeudi - - - vendredi - - - samedi - - - dimanche - à {0} reprises {0} fois @@ -254,4 +233,13 @@ en {0} + + jour + + + jour ouvrable + + + jour du weekend + \ No newline at end of file diff --git a/IcgSoftware.RecurrenceRuleToText/Language.resx b/IcgSoftware.RecurrenceRuleToText/Language.resx index 99f546c..5688b12 100644 --- a/IcgSoftware.RecurrenceRuleToText/Language.resx +++ b/IcgSoftware.RecurrenceRuleToText/Language.resx @@ -166,27 +166,6 @@ MMMM - - Monday - - - Tuesday - - - Wednesday - - - Thursday - - - Friday - - - Saturday - - - Sunday - for {0} times @@ -254,4 +233,13 @@ in {0} + + day + + + weekday + + + weekend days + \ No newline at end of file diff --git a/IcgSoftware.RecurrenceRuleToText/RRuleTextBuilder.cs b/IcgSoftware.RecurrenceRuleToText/RRuleTextBuilder.cs index 37b2c61..21cfaba 100644 --- a/IcgSoftware.RecurrenceRuleToText/RRuleTextBuilder.cs +++ b/IcgSoftware.RecurrenceRuleToText/RRuleTextBuilder.cs @@ -17,19 +17,29 @@ public static class RRuleTextBuilder public static string ToText(this RecurrencePattern recurrencePattern) { - return ToText(recurrencePattern, GetDefaultCulture()); + return ToText(recurrencePattern, GetDefaultCulture(), new DisplayOptions()); } + public static string ToText(this RecurrencePattern recurrencePattern, DisplayOptions options) + { + return ToText(recurrencePattern, GetDefaultCulture(), options); + } + public static string ToText(this RecurrencePattern recurrencePattern, CultureInfo cultureInfo) + { + return ToText(recurrencePattern, cultureInfo, new DisplayOptions()); + } + + public static string ToText(this RecurrencePattern recurrencePattern, CultureInfo cultureInfo, DisplayOptions options) { if (cultureInfo == null) { cultureInfo = GetDefaultCulture(); } - var rRuleTextBuilderIntern = new RRuleTextBuilderIntern(recurrencePattern, cultureInfo); + var rRuleTextBuilderIntern = new RRuleTextBuilderIntern(recurrencePattern, cultureInfo, options); return rRuleTextBuilderIntern.ToText(); } - + public static bool IsWeekdays(this RecurrencePattern recurrencePattern) { List weekDaysR = new List() { DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, DayOfWeek.Thursday, DayOfWeek.Friday }; @@ -37,6 +47,13 @@ public static bool IsWeekdays(this RecurrencePattern recurrencePattern) return weekDaysR.Except(weekDaysP).ToList().Count == 0 && weekDaysP.Except(weekDaysR).ToList().Count == 0; } + public static bool IsWeekendDays(this RecurrencePattern recurrencePattern) + { + List weekDaysR = new List() { DayOfWeek.Sunday, DayOfWeek.Saturday }; + List weekDaysP = recurrencePattern.ByDay.Select(i => i.DayOfWeek).ToList(); + return weekDaysR.Except(weekDaysP).ToList().Count == 0 && weekDaysP.Except(weekDaysR).ToList().Count == 0; + } + public static bool IsEveryDay(this RecurrencePattern recurrencePattern) { List weekDaysR = new List() { DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, DayOfWeek.Thursday, DayOfWeek.Friday, DayOfWeek.Saturday, DayOfWeek.Sunday }; @@ -103,13 +120,15 @@ private class RRuleTextBuilderIntern { private readonly RecurrencePattern recurrencePattern; private readonly CultureInfo ordinalCulture; - - public RRuleTextBuilderIntern(RecurrencePattern recurrencePattern, CultureInfo cultureInfo) + private readonly DisplayOptions displayOptions; + + public RRuleTextBuilderIntern(RecurrencePattern recurrencePattern, CultureInfo cultureInfo, DisplayOptions options) { this.recurrencePattern = recurrencePattern; Language.Culture = cultureInfo; //default language is "en" but ToOrdinalNumber has a default dot ordinalCulture = cultureInfo.Equals(CultureInfo.InvariantCulture) ? new CultureInfo("en") : cultureInfo; + displayOptions = options; } public string ToText() @@ -315,12 +334,32 @@ private String BuildMonthlyOnNumberedDay() return ""; var dayValue = TranslateSetPosNumber(recurrencePattern.BySetPosition.First()); - DayOfWeek dayOfWeek = recurrencePattern.ByDay.Select(i => i.DayOfWeek).First(); - dayValue += " " + GetDayOfWeekString(dayOfWeek); + + dayValue += " " + GetDayOrDayDescription(); + return String.Format(Language.MonthlyOnNumberedDay, dayValue); } - + private string GetDayOrDayDescription() + { + if (IsEveryDay(recurrencePattern)) + { + return Language.Day; + } + else if (IsWeekdays(recurrencePattern)) + { + return Language.Weekday; + } + else if (IsWeekendDays(recurrencePattern)) + { + return Language.WeekendDay; + } + else + { + return GetDayOfWeekString(recurrencePattern.ByDay.Select(i => i.DayOfWeek).First()); + } + } + private string BuildMonthlyOnWeekDay() { if (recurrencePattern.ByDay.Count == 0) @@ -396,11 +435,10 @@ private String BuildYearlyOnNumbered() if (recurrencePattern.BySetPosition.Count == 0 && recurrencePattern.ByDay.Count == 0 && recurrencePattern.ByMonth.Count == 0) return ""; - DayOfWeek dayOfWeek = recurrencePattern.ByDay.Select(i => i.DayOfWeek).First(); DateTime day = new DateTime(DateTime.Today.Year, recurrencePattern.ByMonth.First(), 1); return String.Format(Language.YearlyOnNumbered, TranslateSetPosNumber(recurrencePattern.BySetPosition.First()), - GetDayOfWeekString(dayOfWeek), + GetDayOrDayDescription(), day.ToString(Language.YearlyOnNumberedMonthFormat, Language.Culture)); } @@ -451,24 +489,9 @@ public string FirstCharToUpper(string input) public string GetDayOfWeekString(DayOfWeek dayOfWeek) { - switch (dayOfWeek) - { - case DayOfWeek.Monday: - return Language.Monday; - case DayOfWeek.Tuesday: - return Language.Tuesday; - case DayOfWeek.Wednesday: - return Language.Wednesday; - case DayOfWeek.Thursday: - return Language.Thursday; - case DayOfWeek.Friday: - return Language.Friday; - case DayOfWeek.Saturday: - return Language.Saturday; - case DayOfWeek.Sunday: - default: - return Language.Sunday; - } + return displayOptions.ShortWeekdays + ? ordinalCulture.DateTimeFormat.ShortestDayNames[(int)dayOfWeek] + : ordinalCulture.DateTimeFormat.DayNames[(int)dayOfWeek]; } } diff --git a/createNugetpackages.ps1 b/createNugetpackages.ps1 new file mode 100644 index 0000000..0ee4a64 --- /dev/null +++ b/createNugetpackages.ps1 @@ -0,0 +1,69 @@ +#REQUIRES -Version 2.0 + +<# +.SYNOPSIS + Create a nuget package for defined projects. +.DESCRIPTION + Create a nuget package for a list of defined projects and push each to our nuget server. +.NOTES + Requirements : installed nuget.exe and msbuild.exe + Copyright 2022 - RECOM GmbH +#> + + +Set-StrictMode -Version 2.0 +$ErrorActionPreference = 'Stop' + +# list of projects for which a nuget package should be created +$projectDirs = @('IcgSoftware.RecurrenceRuleToText') + +function buildSolution { + Write-Host 'Building solution..' + $msBuildExe = '' + if (Test-Path env:JENKINS_HOME) { + $msBuildExe = 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\bin\msbuild.exe' + } else { + $msBuildExe = 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\MSBuild.exe' + } + + $argumentList = '.\\IcgSoftware.RecurrenceRuleToText.sln /m:4 /nodeReuse:false /p:Configuration=Release /p:Platform="Any CPU" /p:SkipNativeBuilds=true /t:Build /nr:false' + Start-Process $msBuildExe -ArgumentList $argumentList -NoNewWindow -Wait +} + +function createNugetPackages { + $nugetCLI = 'nuget.exe'; + + $copyRight = 'We do not want anyone to see our source code, but if for any reason our code is stolen or otherwise obtained, we want to have a license that does not allow disclosure of any kind.' + + foreach ($projectDir in $projectDirs){ + Write-Host "Start creating nuget package for project '$projectDir'" + try + { + Push-Location $projectDir + & $nugetCLI spec -Force -Verbosity detailed + $nuspecs = Get-ChildItem -Path .\ -Filter '*.nuspec' + $nuspec = $nuspecs[0].Name + if(-not (Test-Path $nuspec)) {throw "Could nod find .nuspec file '$nuspec'"} + (Get-Content $nuspec) -replace '.*',"Branch: $branch" ` + -replace '.*',"RECOM_API $branch $projectDir" ` + -replace '.*',"" ` + -replace '.*',"" ` + -replace '.*',"" ` + -replace ' defaultPushSource + } + finally + { + Pop-Location + } + } +} + +buildSolution; +createNugetPackages \ No newline at end of file