Skip to content

Commit 3143fc4

Browse files
author
Nick Berardi
committed
Added support for changing raw unix time to DateTime.
1 parent dbb7241 commit 3143fc4

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

RestSharp/Extensions/StringExtensions.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,13 @@ public static DateTime ParseJsonDate(this string input, CultureInfo culture)
101101

102102
input = input.RemoveSurroundingQuotes();
103103

104+
long unix;
105+
if (Int64.TryParse(input, out unix))
106+
{
107+
var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
108+
return epoch.AddSeconds(unix);
109+
}
110+
104111
if (input.Contains("/Date("))
105112
{
106113
return ExtractDate(input, @"\\/Date\((-?\d+)(-|\+)?([0-9]{4})?\)\\/", culture);

0 commit comments

Comments
 (0)