Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion cmd/page.go
Original file line number Diff line number Diff line change
Expand Up @@ -1093,8 +1093,13 @@ func buildPropertyValue(propType, value string) interface{} {
"status": map[string]interface{}{"name": value},
}
case "date":
parts := strings.SplitN(value, "/", 2)
d := map[string]interface{}{"start": parts[0]}
if len(parts) == 2 {
d["end"] = parts[1]
}
return map[string]interface{}{
"date": map[string]interface{}{"start": value},
"date": d,
}
case "checkbox":
return map[string]interface{}{
Expand Down
24 changes: 24 additions & 0 deletions cmd/page_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,30 @@ func TestBuildPropertyValueMultiSelect(t *testing.T) {
}
}

func TestBuildPropertyValueDateRange(t *testing.T) {
// Single date (backward compatible)
result := buildPropertyValue("date", "2026-03-07")
m := result.(map[string]interface{})
d := m["date"].(map[string]interface{})
if d["start"] != "2026-03-07" {
t.Errorf("start = %q, want 2026-03-07", d["start"])
}
if _, hasEnd := d["end"]; hasEnd {
t.Error("single date should not have end key")
}

// Date range with /
result2 := buildPropertyValue("date", "2026-03-07T20:00:00+01:00/2026-03-07T21:00:00+01:00")
m2 := result2.(map[string]interface{})
d2 := m2["date"].(map[string]interface{})
if d2["start"] != "2026-03-07T20:00:00+01:00" {
t.Errorf("start = %q, want 2026-03-07T20:00:00+01:00", d2["start"])
}
if d2["end"] != "2026-03-07T21:00:00+01:00" {
t.Errorf("end = %q, want 2026-03-07T21:00:00+01:00", d2["end"])
}
}

func TestBuildPropertyValueTitle(t *testing.T) {
result := buildPropertyValue("title", "My Title")
m := result.(map[string]interface{})
Expand Down