Skip to content

Commit 9bddacb

Browse files
committed
Fixed date time displaying (null for empty/not set dates)
1 parent ef32ebf commit 9bddacb

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

opengraph/opengraph.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ type Audio struct {
3636

3737
// Article contain Open Graph Article structure
3838
type Article struct {
39-
PublishedTime time.Time `json:"published_time"`
40-
ModifiedTime time.Time `json:"modified_time"`
41-
ExpirationTime time.Time `json:"expiration_time"`
39+
PublishedTime *time.Time `json:"published_time"`
40+
ModifiedTime *time.Time `json:"modified_time"`
41+
ExpirationTime *time.Time `json:"expiration_time"`
4242
Section string `json:"section"`
4343
Tags []string `json:"tags"`
4444
Authors []*Profile `json:"authors"`
@@ -55,7 +55,7 @@ type Profile struct {
5555
// Book contains Open Graph Book structure
5656
type Book struct {
5757
ISBN string `json:"isbn"`
58-
ReleaseDate time.Time `json:"release_date"`
58+
ReleaseDate *time.Time `json:"release_date"`
5959
Tags []string `json:"tags"`
6060
Authors []*Profile `json:"authors"`
6161
}
@@ -244,17 +244,17 @@ func (og *OpenGraph) processArticleMeta(metaAttrs map[string]string) {
244244
case "article:published_time":
245245
t, err := time.Parse(time.RFC3339, metaAttrs["content"])
246246
if err == nil {
247-
og.Article.PublishedTime = t
247+
og.Article.PublishedTime = &t
248248
}
249249
case "article:modified_time":
250250
t, err := time.Parse(time.RFC3339, metaAttrs["content"])
251251
if err == nil {
252-
og.Article.ModifiedTime = t
252+
og.Article.ModifiedTime = &t
253253
}
254254
case "article:expiration_time":
255255
t, err := time.Parse(time.RFC3339, metaAttrs["content"])
256256
if err == nil {
257-
og.Article.ExpirationTime = t
257+
og.Article.ExpirationTime = &t
258258
}
259259
case "article:secttion":
260260
og.Article.Section = metaAttrs["content"]
@@ -291,7 +291,7 @@ func (og *OpenGraph) processBookMeta(metaAttrs map[string]string) {
291291
case "book:release_date":
292292
t, err := time.Parse(time.RFC3339, metaAttrs["content"])
293293
if err == nil {
294-
og.Book.ReleaseDate = t
294+
og.Book.ReleaseDate = &t
295295
}
296296
case "book:isbn":
297297
og.Book.ISBN = metaAttrs["content"]

0 commit comments

Comments
 (0)