From b4c99e5f2e5a22c405339bb23c14490af753285e Mon Sep 17 00:00:00 2001 From: luke-josh Date: Tue, 27 Aug 2024 09:06:25 +1000 Subject: [PATCH] Add required format field to rich text date blocks --- block_rich_text.go | 4 +++- block_rich_text_test.go | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/block_rich_text.go b/block_rich_text.go index b6a4b4ce4..0437ab72b 100644 --- a/block_rich_text.go +++ b/block_rich_text.go @@ -414,16 +414,18 @@ func NewRichTextSectionUserGroupElement(usergroupID string) *RichTextSectionUser type RichTextSectionDateElement struct { Type RichTextSectionElementType `json:"type"` Timestamp JSONTime `json:"timestamp"` + Format string `json:"format"` } func (r RichTextSectionDateElement) RichTextSectionElementType() RichTextSectionElementType { return r.Type } -func NewRichTextSectionDateElement(timestamp int64) *RichTextSectionDateElement { +func NewRichTextSectionDateElement(timestamp int64, format string) *RichTextSectionDateElement { return &RichTextSectionDateElement{ Type: RTSEDate, Timestamp: JSONTime(timestamp), + Format: format, } } diff --git a/block_rich_text_test.go b/block_rich_text_test.go index a9f04b7de..1456b3661 100644 --- a/block_rich_text_test.go +++ b/block_rich_text_test.go @@ -167,13 +167,13 @@ 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}"}]}`), 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}"}, }, }, nil,