diff --git a/block_rich_text.go b/block_rich_text.go index b6a4b4ce4..611763ad4 100644 --- a/block_rich_text.go +++ b/block_rich_text.go @@ -414,16 +414,22 @@ func NewRichTextSectionUserGroupElement(usergroupID string) *RichTextSectionUser type RichTextSectionDateElement struct { Type RichTextSectionElementType `json:"type"` Timestamp JSONTime `json:"timestamp"` + Format string `json:"format"` + URL *string `json:"url,omitempty"` + Fallback *string `json:"fallback,omitempty"` } func (r RichTextSectionDateElement) RichTextSectionElementType() RichTextSectionElementType { return r.Type } -func NewRichTextSectionDateElement(timestamp int64) *RichTextSectionDateElement { +func NewRichTextSectionDateElement(timestamp int64, format string, url *string, fallback *string) *RichTextSectionDateElement { return &RichTextSectionDateElement{ Type: RTSEDate, Timestamp: JSONTime(timestamp), + Format: format, + URL: url, + Fallback: fallback, } } diff --git a/block_rich_text_test.go b/block_rich_text_test.go index a9f04b7de..dec73ad9f 100644 --- a/block_rich_text_test.go +++ b/block_rich_text_test.go @@ -167,13 +167,14 @@ func TestRichTextSection_UnmarshalJSON(t *testing.T) { err error }{ { - []byte(`{"elements":[{"type":"unknown","value":10},{"type":"text","text":"hi"},{"type":"date","timestamp":1636961629}]}`), + []byte(`{"elements":[{"type":"unknown","value":10},{"type":"text","text":"hi"},{"type":"date","timestamp":1636961629,"format":"{date_short_pretty}"},{"type":"date","timestamp":1636961629,"format":"{date_short_pretty}","url":"https://example.com","fallback":"default"}]}`), RichTextSection{ Type: RTESection, Elements: []RichTextSectionElement{ &RichTextSectionUnknownElement{Type: RTSEUnknown, Raw: `{"type":"unknown","value":10}`}, &RichTextSectionTextElement{Type: RTSEText, Text: "hi"}, - &RichTextSectionDateElement{Type: RTSEDate, Timestamp: JSONTime(1636961629)}, + &RichTextSectionDateElement{Type: RTSEDate, Timestamp: JSONTime(1636961629), Format: "{date_short_pretty}"}, + &RichTextSectionDateElement{Type: RTSEDate, Timestamp: JSONTime(1636961629), Format: "{date_short_pretty}", URL: strp("https://example.com"), Fallback: strp("default")}, }, }, nil, @@ -361,3 +362,5 @@ func TestRichTextQuote_Marshal(t *testing.T) { } }) } + +func strp(in string) *string { return &in }