Skip to content

Commit 34ff6e1

Browse files
committed
Parse Timex property hourAmount, minuteAmount + secondAmount as decimal instead of int #3106
1 parent 6f0b085 commit 34ff6e1

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

.NET/Microsoft.Recognizers.Text.DataTypes.DataDrivenTests/TestTimexParsing.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,7 @@ public void DataTypes_Parsing_DurationDays()
10941094
[TestMethod]
10951095
public void DataTypes_Parsing_DurationHours()
10961096
{
1097-
var timex = new TimexProperty("PT5H");
1097+
var timex = new TimexProperty("PT5.5H");
10981098
CollectionAssert.AreEquivalent(new[] { Constants.TimexTypes.Duration }, timex.Types.ToList());
10991099

11001100
Assert.IsNull(timex.Year);
@@ -1113,7 +1113,7 @@ public void DataTypes_Parsing_DurationHours()
11131113
Assert.IsNull(timex.Months);
11141114
Assert.IsNull(timex.Weeks);
11151115
Assert.IsNull(timex.Days);
1116-
Assert.AreEqual(5, timex.Hours);
1116+
Assert.AreEqual(5.5m, timex.Hours);
11171117
Assert.IsNull(timex.Minutes);
11181118
Assert.IsNull(timex.Seconds);
11191119
Assert.IsNull(timex.Now);
@@ -1122,7 +1122,7 @@ public void DataTypes_Parsing_DurationHours()
11221122
[TestMethod]
11231123
public void DataTypes_Parsing_DurationMinutes()
11241124
{
1125-
var timex = new TimexProperty("PT30M");
1125+
var timex = new TimexProperty("PT30.5M");
11261126
CollectionAssert.AreEquivalent(new[] { Constants.TimexTypes.Duration }, timex.Types.ToList());
11271127

11281128
Assert.IsNull(timex.Year);
@@ -1142,15 +1142,15 @@ public void DataTypes_Parsing_DurationMinutes()
11421142
Assert.IsNull(timex.Weeks);
11431143
Assert.IsNull(timex.Days);
11441144
Assert.IsNull(timex.Hours);
1145-
Assert.AreEqual(30, timex.Minutes);
1145+
Assert.AreEqual(30.5m, timex.Minutes);
11461146
Assert.IsNull(timex.Seconds);
11471147
Assert.IsNull(timex.Now);
11481148
}
11491149

11501150
[TestMethod]
11511151
public void DataTypes_Parsing_DurationSeconds()
11521152
{
1153-
var timex = new TimexProperty("PT45S");
1153+
var timex = new TimexProperty("PT45.5S");
11541154
CollectionAssert.AreEquivalent(new[] { Constants.TimexTypes.Duration }, timex.Types.ToList());
11551155

11561156
Assert.IsNull(timex.Year);
@@ -1171,7 +1171,7 @@ public void DataTypes_Parsing_DurationSeconds()
11711171
Assert.IsNull(timex.Days);
11721172
Assert.IsNull(timex.Hours);
11731173
Assert.IsNull(timex.Minutes);
1174-
Assert.AreEqual(45, timex.Seconds);
1174+
Assert.AreEqual(45.5m, timex.Seconds);
11751175
Assert.IsNull(timex.Now);
11761176
}
11771177
}

.NET/Microsoft.Recognizers.Text.DataTypes.TimexExpression/TimexProperty.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,15 +259,15 @@ public void AssignProperties(IDictionary<string, string> source)
259259
break;
260260

261261
case "hourAmount":
262-
Hours = int.Parse(item.Value, CultureInfo.InvariantCulture);
262+
Hours = decimal.Parse(item.Value, CultureInfo.InvariantCulture);
263263
break;
264264

265265
case "minuteAmount":
266-
Minutes = int.Parse(item.Value, CultureInfo.InvariantCulture);
266+
Minutes = decimal.Parse(item.Value, CultureInfo.InvariantCulture);
267267
break;
268268

269269
case "secondAmount":
270-
Seconds = int.Parse(item.Value, CultureInfo.InvariantCulture);
270+
Seconds = decimal.Parse(item.Value, CultureInfo.InvariantCulture);
271271
break;
272272
}
273273
}

0 commit comments

Comments
 (0)