Skip to content

Commit

Permalink
Parse Timex property hourAmount, minuteAmount + secondAmount as decim…
Browse files Browse the repository at this point in the history
…al instead of int microsoft#3106
  • Loading branch information
Sebastian Schubotz committed May 22, 2023
1 parent 6f0b085 commit 34ff6e1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,7 @@ public void DataTypes_Parsing_DurationDays()
[TestMethod]
public void DataTypes_Parsing_DurationHours()
{
var timex = new TimexProperty("PT5H");
var timex = new TimexProperty("PT5.5H");
CollectionAssert.AreEquivalent(new[] { Constants.TimexTypes.Duration }, timex.Types.ToList());

Assert.IsNull(timex.Year);
Expand All @@ -1113,7 +1113,7 @@ public void DataTypes_Parsing_DurationHours()
Assert.IsNull(timex.Months);
Assert.IsNull(timex.Weeks);
Assert.IsNull(timex.Days);
Assert.AreEqual(5, timex.Hours);
Assert.AreEqual(5.5m, timex.Hours);
Assert.IsNull(timex.Minutes);
Assert.IsNull(timex.Seconds);
Assert.IsNull(timex.Now);
Expand All @@ -1122,7 +1122,7 @@ public void DataTypes_Parsing_DurationHours()
[TestMethod]
public void DataTypes_Parsing_DurationMinutes()
{
var timex = new TimexProperty("PT30M");
var timex = new TimexProperty("PT30.5M");
CollectionAssert.AreEquivalent(new[] { Constants.TimexTypes.Duration }, timex.Types.ToList());

Assert.IsNull(timex.Year);
Expand All @@ -1142,15 +1142,15 @@ public void DataTypes_Parsing_DurationMinutes()
Assert.IsNull(timex.Weeks);
Assert.IsNull(timex.Days);
Assert.IsNull(timex.Hours);
Assert.AreEqual(30, timex.Minutes);
Assert.AreEqual(30.5m, timex.Minutes);
Assert.IsNull(timex.Seconds);
Assert.IsNull(timex.Now);
}

[TestMethod]
public void DataTypes_Parsing_DurationSeconds()
{
var timex = new TimexProperty("PT45S");
var timex = new TimexProperty("PT45.5S");
CollectionAssert.AreEquivalent(new[] { Constants.TimexTypes.Duration }, timex.Types.ToList());

Assert.IsNull(timex.Year);
Expand All @@ -1171,7 +1171,7 @@ public void DataTypes_Parsing_DurationSeconds()
Assert.IsNull(timex.Days);
Assert.IsNull(timex.Hours);
Assert.IsNull(timex.Minutes);
Assert.AreEqual(45, timex.Seconds);
Assert.AreEqual(45.5m, timex.Seconds);
Assert.IsNull(timex.Now);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,15 +259,15 @@ public void AssignProperties(IDictionary<string, string> source)
break;

case "hourAmount":
Hours = int.Parse(item.Value, CultureInfo.InvariantCulture);
Hours = decimal.Parse(item.Value, CultureInfo.InvariantCulture);
break;

case "minuteAmount":
Minutes = int.Parse(item.Value, CultureInfo.InvariantCulture);
Minutes = decimal.Parse(item.Value, CultureInfo.InvariantCulture);
break;

case "secondAmount":
Seconds = int.Parse(item.Value, CultureInfo.InvariantCulture);
Seconds = decimal.Parse(item.Value, CultureInfo.InvariantCulture);
break;
}
}
Expand Down

0 comments on commit 34ff6e1

Please sign in to comment.