Skip to content
This repository was archived by the owner on Sep 20, 2022. It is now read-only.

Commit c6533f5

Browse files
author
Jake Ginnivan
committed
Better release date parsing
1 parent 322c8db commit c6533f5

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

src/GitReleaseNotes/SemanticReleaseNotes.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,29 @@ public static SemanticReleaseNotes Parse(string releaseNotes)
102102
currentRelease.ReleaseName = null;
103103

104104
if (match.Groups["Date"].Success)
105-
currentRelease.When = DateTime.ParseExact(match.Groups["Date"].Value, "dd MMMM yyyy", CultureInfo.CurrentCulture);
105+
{
106+
DateTime parsed;
107+
var toParse = match.Groups["Date"].Value;
108+
if (DateTime.TryParse(toParse, out parsed))
109+
{
110+
currentRelease.When = parsed;
111+
}
112+
if (DateTime.TryParseExact(toParse, "dd MMMM yyyy", CultureInfo.InvariantCulture,
113+
DateTimeStyles.None, out parsed))
114+
{
115+
currentRelease.When = parsed;
116+
}
117+
else if (DateTime.TryParseExact(toParse, "MMMM dd, yyyy", CultureInfo.InvariantCulture,
118+
DateTimeStyles.None, out parsed))
119+
{
120+
currentRelease.When = parsed;
121+
}
122+
else
123+
{
124+
// We failed to parse the date, just append to the end
125+
currentRelease.ReleaseName += " (" + toParse + ")";
126+
}
127+
}
106128
}
107129
else if (line.StartsWith("Commits: "))
108130
{

0 commit comments

Comments
 (0)