@@ -31,7 +31,7 @@ public class WordPressExportItem
31
31
/// <summary>
32
32
/// The post_date_gmt element's value.
33
33
/// </summary>
34
- public DateTime PostDateGmt { get ; set ; }
34
+ public DateTime ? PostDateGmt { get ; set ; }
35
35
36
36
/// <summary>
37
37
/// The post_modified element's value.
@@ -41,7 +41,7 @@ public class WordPressExportItem
41
41
/// <summary>
42
42
/// The post_modified_gmt element's value.
43
43
/// </summary>
44
- public DateTime PostModifiedGmt { get ; set ; }
44
+ public DateTime ? PostModifiedGmt { get ; set ; }
45
45
46
46
/// <summary>
47
47
/// The comment_status element's value.
@@ -109,9 +109,14 @@ public WordPressExportItem(XElement itemElement)
109
109
110
110
PostId = Helpers . TryParseLong ( itemElement . GetChildElementValue ( namespacePrefix : WordPressExportChannel . NamespacePrefix , elementName : "post_id" ) ) ! . Value ;
111
111
PostDate = Helpers . TryParseDateTime ( itemElement . GetChildElementValue ( namespacePrefix : WordPressExportChannel . NamespacePrefix , elementName : "post_date" ) ) ! . Value ;
112
- PostDateGmt = itemElement . GetChildElementValue ( namespacePrefix : WordPressExportChannel . NamespacePrefix , elementName : "post_date_gmt" ) . ParseUtcOrDefault ( ) ! . Value ;
112
+
113
+ // We can't assume that a post will have a valid GMT date. One of my entries did not.
114
+ PostDateGmt = itemElement . GetChildElementValue ( namespacePrefix : WordPressExportChannel . NamespacePrefix , elementName : "post_date_gmt" ) . ParseUtcOrDefault ( ) ;
115
+
113
116
PostModified = Helpers . TryParseDateTime ( itemElement . GetChildElementValue ( namespacePrefix : WordPressExportChannel . NamespacePrefix , elementName : "post_modified" ) ) ! . Value ;
114
- PostModifiedGmt = itemElement . GetChildElementValue ( namespacePrefix : WordPressExportChannel . NamespacePrefix , elementName : "post_modified_gmt" ) . ParseUtcOrDefault ( ) ! . Value ;
117
+
118
+ // We can't assume that a post will have a valid GMT date. One of my entries did not.
119
+ PostModifiedGmt = itemElement . GetChildElementValue ( namespacePrefix : WordPressExportChannel . NamespacePrefix , elementName : "post_modified_gmt" ) . ParseUtcOrDefault ( ) ;
115
120
116
121
CommentStatus = itemElement . GetChildElementValue ( namespacePrefix : WordPressExportChannel . NamespacePrefix , elementName : "comment_status" ) ! ;
117
122
PingStatus = itemElement . GetChildElementValue ( namespacePrefix : WordPressExportChannel . NamespacePrefix , elementName : "ping_status" ) ! ;
0 commit comments