From 5f9fc2a8667a9438b6336d75026f9a455fc9c4ce Mon Sep 17 00:00:00 2001 From: grm Date: Mon, 14 Sep 2026 22:58:08 +0300 Subject: Let the blogger set a post's date, when writing it and afterwards The post date is posts.created_at: it already drives ordering, the archive, the feed and the displayed dates, so making it editable is a form field rather than a new column. The datetime-local input degrades to a text box on old browsers, so the server also accepts the value typed by hand; blank keeps the current date. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01Sd8UPWrvyYCLj97JexNw3A --- internal/web/web_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'internal/web/web_test.go') diff --git a/internal/web/web_test.go b/internal/web/web_test.go index ae26029..d7de43a 100644 --- a/internal/web/web_test.go +++ b/internal/web/web_test.go @@ -220,6 +220,24 @@ func TestValidLinkURL(t *testing.T) { } } +func TestParsePostDate(t *testing.T) { + for in, want := range map[string]time.Time{ + "2026-09-14T08:30": time.Date(2026, 9, 14, 8, 30, 0, 0, time.Local), + "2026-09-14 08:30": time.Date(2026, 9, 14, 8, 30, 0, 0, time.Local), + "2026-09-14T08:30:15": time.Date(2026, 9, 14, 8, 30, 15, 0, time.Local), + "2026-09-14": time.Date(2026, 9, 14, 0, 0, 0, 0, time.Local), + } { + if got, ok := parsePostDate(in); !ok || !got.Equal(want) { + t.Errorf("%q: got %v %v, want %v", in, got, ok, want) + } + } + for _, bad := range []string{"", "14/09/2026", "2026-13-01", "yesterday", "2026-09-14T25:00"} { + if _, ok := parsePostDate(bad); ok { + t.Errorf("%q should be rejected", bad) + } + } +} + func TestGroupArchive(t *testing.T) { d := func(y int, m time.Month, day int) time.Time { return time.Date(y, m, day, 12, 0, 0, 0, time.UTC) } posts := []store.PostRef{{Title: "d", CreatedAt: d(2026, 9, 3)}, {Title: "c", CreatedAt: d(2026, 9, 1)}, {Title: "b", CreatedAt: d(2026, 2, 1)}, {Title: "a", CreatedAt: d(2025, 12, 31)}} -- cgit v1.2.3