Skip to content

Commit b3f4cb8

Browse files
committed
Fix date time iso8601 serializer
1 parent bfa0292 commit b3f4cb8

File tree

3 files changed

+7
-42
lines changed

3 files changed

+7
-42
lines changed

CHANGES.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,19 @@ twilio-csharp Changelog
33

44
[2017-06-30] Version 5.5.2
55
---------------------------
6+
- Fix Url parameters with percent encoded characters not being properly serialized before being sent to the API.
7+
- Fix Iso8601 date time serialization not enforcing expected culture, timezone. Issue #372.
8+
- Support Recording encryption. Add `EncryptionType` and `EncryptionDetails` parameters to call recordings.
9+
- Add new usage record categories for rooms and speech recognition.
610

711
**Video**
8-
912
- Filter recordings by date using the parameters `DateCreatedAfter` and `DateCreatedBefore`.
1013
- Override the default time-to-live of a recording's media URL through the `Ttl` parameter (in seconds, default value is 3600).
1114
- Add query parameters `SourceSid`, `Status`, `DateCreatedAfter` and `DateCreatedBefore` to the convenience method for retrieving Room recordings.
12-
**Wireless**
1315

16+
**Wireless**
1417
- Added national and international data limits to the RatePlans resource.
1518

16-
1719
[2017-06-16] Version 5.5.1
1820
--------------------------
1921
- Make url parameter optional in Play Twiml.

src/Twilio/Converters/Serializers.cs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,11 @@ public static string JsonObject(object input)
2525
/// </summary>
2626
/// <param name="input">DateTime instance to serialize to string</param>
2727
/// <returns>A string</returns>
28-
public static string DateTimeIso8601(DateTime input)
29-
{
30-
return input.ToString("yyyy-MM-ddTHH:mm:ssZ");
31-
}
32-
33-
/// <summary>
34-
/// Produce a ISO 8601 UTC compatible string from input if possible
35-
/// </summary>
36-
/// <param name="input">string representation of a time which will be converted to an iso8601 UTC string</param>
37-
/// <returns>A string</returns>
38-
public static string DateTimeIso8601(string input)
28+
public static string DateTimeIso8601(DateTime? input)
3929
{
4030
if (input == null) return null;
4131

42-
var enUS = new CultureInfo("en-US");
43-
var utc = DateTimeStyles.AdjustToUniversal;
44-
DateTime parsedDateTime;
45-
46-
return DateTime.TryParse(input, enUS, utc, out parsedDateTime) ? DateTimeIso8601(parsedDateTime) : input;
32+
return input.Value.ToString("yyyy-MM-ddTHH:mm:ssZ");
4733
}
4834
}
4935
}

test/Twilio.Test/Converters/SerializersTest.cs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -52,34 +52,11 @@ public void TestDateTimeIso8601WithDateTime()
5252
Assert.AreEqual(expect, result);
5353
}
5454

55-
[Test]
56-
public void TestDateTimeIso8601WithString()
57-
{
58-
var input = "2017-06-19T12:13:14Z";
59-
var result = Serializers.DateTimeIso8601(input);
60-
Assert.AreEqual(input, result);
61-
}
62-
63-
[Test]
64-
public void TestDateTimeIso8601WithStringConvertsTZ()
65-
{
66-
var result = Serializers.DateTimeIso8601("2017-06-19T11:13:14-01:00");
67-
Assert.AreEqual("2017-06-19T12:13:14Z", result);
68-
}
69-
7055
[Test]
7156
public void TestDateTimeIso8601WithNull()
7257
{
7358
var result = Serializers.DateTimeIso8601(null);
7459
Assert.AreEqual(null, result);
7560
}
76-
77-
[Test]
78-
public void TestDateTimeIso8601WithGarbage()
79-
{
80-
var result = Serializers.DateTimeIso8601("not-a-time");
81-
Assert.AreEqual("not-a-time", result);
82-
}
83-
8461
}
8562
}

0 commit comments

Comments
 (0)