Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse Timex property hourAmount, minuteAmount + secondAmount as decimal #3107

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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