Skip to content

Commit 53b4ab5

Browse files
filbergandersnm
authored andcommitted
Fix DateTime formatting with uppercase formatCode
Use case-insensitive comparison when checking "m" codes for month/minute difference. This corrects DateTime formatting when xlsx "formatCode" attrube is uppercase (e.g. HH:MM:SS) otherwise the date is formatted with the month part in place of the minutes one.
1 parent a10c666 commit 53b4ab5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/ExcelNumberFormat/Formatter.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ private static bool LookAheadDatePart(List<string> tokens, int fromIndex, string
272272
for (var i = fromIndex; i < tokens.Count; i++)
273273
{
274274
var token = tokens[i];
275-
if (token.StartsWith(startsWith))
275+
if (token.StartsWith(startsWith, StringComparison.OrdinalIgnoreCase))
276276
return true;
277277
if (Token.IsDatePart(token))
278278
return false;
@@ -286,7 +286,7 @@ private static bool LookBackDatePart(List<string> tokens, int fromIndex, string
286286
for (var i = fromIndex; i >= 0; i--)
287287
{
288288
var token = tokens[i];
289-
if (token.StartsWith(startsWith))
289+
if (token.StartsWith(startsWith, StringComparison.OrdinalIgnoreCase))
290290
return true;
291291
if (Token.IsDatePart(token))
292292
return false;

0 commit comments

Comments
 (0)