mirror of
https://gitea.phreedom.club/localhost_frssoft/bloat.git
synced 2024-11-22 12:49:21 +02:00
Fix time parsing for empty string
This commit is contained in:
parent
b2a9e44db1
commit
1c8c661abb
|
@ -19,6 +19,19 @@ type ReplyInfo struct {
|
||||||
Number int `json:"number"`
|
Number int `json:"number"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type CreatedAt struct {
|
||||||
|
time.Time
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *CreatedAt) UnmarshalJSON(d []byte) error {
|
||||||
|
// Special case to handle retweets from GNU Social
|
||||||
|
// which returns empty string ("") in created_at
|
||||||
|
if len(d) == 2 && string(d) == `""` {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return t.Time.UnmarshalJSON(d)
|
||||||
|
}
|
||||||
|
|
||||||
// Status is struct to hold status.
|
// Status is struct to hold status.
|
||||||
type Status struct {
|
type Status struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
|
@ -29,7 +42,7 @@ type Status struct {
|
||||||
InReplyToAccountID interface{} `json:"in_reply_to_account_id"`
|
InReplyToAccountID interface{} `json:"in_reply_to_account_id"`
|
||||||
Reblog *Status `json:"reblog"`
|
Reblog *Status `json:"reblog"`
|
||||||
Content string `json:"content"`
|
Content string `json:"content"`
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt CreatedAt `json:"created_at"`
|
||||||
Emojis []Emoji `json:"emojis"`
|
Emojis []Emoji `json:"emojis"`
|
||||||
RepliesCount int64 `json:"replies_count"`
|
RepliesCount int64 `json:"replies_count"`
|
||||||
ReblogsCount int64 `json:"reblogs_count"`
|
ReblogsCount int64 `json:"reblogs_count"`
|
||||||
|
|
|
@ -227,8 +227,8 @@
|
||||||
<div class="status-action status-action-last">
|
<div class="status-action status-action-last">
|
||||||
<a class="status-time" href="{{if not .ShowReplies}}/thread/{{.ID}}{{end}}#status-{{.ID}}"
|
<a class="status-time" href="{{if not .ShowReplies}}/thread/{{.ID}}{{end}}#status-{{.ID}}"
|
||||||
{{if $.Ctx.ThreadInNewTab}}target="_blank"{{end}}>
|
{{if $.Ctx.ThreadInNewTab}}target="_blank"{{end}}>
|
||||||
<time datetime="{{FormatTimeRFC3339 .CreatedAt}}" title="{{FormatTimeRFC822 .CreatedAt}}">
|
<time datetime="{{FormatTimeRFC3339 .CreatedAt.Time}}" title="{{FormatTimeRFC822 .CreatedAt.Time}}">
|
||||||
{{TimeSince .CreatedAt}}
|
{{TimeSince .CreatedAt.Time}}
|
||||||
</time>
|
</time>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue