From c9fd3eea6c58d1bee394c805e9991d4e048c21d5 Mon Sep 17 00:00:00 2001 From: Peter Khouri Date: Wed, 18 Oct 2017 20:48:05 -0400 Subject: [PATCH] Added null check before converting Timestamp to DateTime Updated .gitignore --- .gitignore | 1 + src/prismic/Fragment.cs | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index e65a0e0..b0cc30c 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,4 @@ src/nuget/packaging/ node_modules/ +src/.vs \ No newline at end of file diff --git a/src/prismic/Fragment.cs b/src/prismic/Fragment.cs index fa58513..ac206d5 100644 --- a/src/prismic/Fragment.cs +++ b/src/prismic/Fragment.cs @@ -405,10 +405,14 @@ public Timestamp(DateTime value) { public String AsHtml() { return (""); } - public static Timestamp Parse(JToken json) { - return new Timestamp(json.ToObject()); - } - } + public static Timestamp Parse(JToken json) + { + if (((JValue)json).Value == null) + return new Timestamp(DateTime.MinValue); + else + return new Timestamp(json.ToObject()); + } + } public class Embed: Fragment { private String type;