We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 23aeebc commit e22066eCopy full SHA for e22066e
2 files changed
StrftimeParser/Strftime.cs
@@ -108,9 +108,12 @@ public static DateTime Parse(string input, string format, CultureInfo culture)
108
// Year divided by 100
109
if (elements.YearDividedBy100 != null)
110
{
111
- var yearDivided = Formatter.ParseYearDividedBy100(elements.YearDividedBy100);
112
- if (year != null && !yearDivided.Equals(year / 100)) throw new FormatException("Incoherent year");
113
- year = yearDivided * 100;
+ if (year == null) year = 1970;
+ else
+ {
114
+ var yearDivided = Formatter.ParseYearDividedBy100(elements.YearDividedBy100);
115
+ if (year != null && !yearDivided.Equals(year / 100)) throw new FormatException("Incoherent year");
116
+ }
117
}
118
119
// Day of the month
test/StrftimeParserTest/ParserTest.cs
@@ -155,12 +155,12 @@ public void ParseShortYyyyMmDd(string input, string format, int year, int month,
155
156
157
[Theory]
158
- [InlineData("20", "%C", 2000)]
159
- [InlineData("23", "%C", 2300)]
160
- [InlineData("19", "%C", 1900)]
161
- [InlineData("03", "%C", 300)]
162
- [InlineData("20 2023", "%C %Y", 2000)]
163
- [InlineData("19 1975", "%C %Y", 1900)]
+ [InlineData("20", "%C", 1970)]
+ [InlineData("23", "%C", 1970)]
+ [InlineData("19", "%C", 1970)]
+ [InlineData("03", "%C", 1970)]
+ [InlineData("20 2023", "%C %Y", 2023)]
+ [InlineData("19 1975", "%C %Y", 1975)]
164
public void ParseYearDividedBy100(string input, string format, int expectedYear)
165
166
var res = Strftime.Parse(input, format, _culture);
0 commit comments