Skip to content

Commit

Permalink
Add required format field to rich text date blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
luke-josh committed Aug 26, 2024
1 parent 5386d65 commit b4c99e5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion block_rich_text.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

Expand Down
4 changes: 2 additions & 2 deletions block_rich_text_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit b4c99e5

Please sign in to comment.