Configure date and time formatting independently#105
Merged
methodofaction merged 3 commits intomainfrom Apr 27, 2026
Merged
Conversation
When a document has both an issue date and an issue time, rendering went through a separate `CalFormatter.DateTime` template (default ISO `2006-01-02 · 15:04`). A user-supplied `date_format` only overrode `CalFormatter.Date`, so date+time fields silently kept the ISO date format and the user's preference was lost. Replace `CalFormatter.DateTime` with a `Time` field (default `15:04`) and compose `cal.DateTime` rendering as `<Date><sep><Time>`. This guarantees the user's date format always applies, and lets time be configured independently. Add a new `time_format` query param to the CLI server. Public API change: the second parameter of `WithCalFormatter` is now a time-only template (e.g. `15:04`) instead of a combined date-time template. The only in-repo caller passed `""` so it is unaffected; external callers passing a full datetime template will need to update. Fixes APP-472 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
There was a problem hiding this comment.
Pull request overview
Updates calendar formatting so date and time can be configured independently, ensuring date_format is always honored even when documents include an issue time (APP-472).
Changes:
- Replace
CalFormatter.DateTimewith a dedicatedTimeformat and rendercal.DateTimeas<date> · <time>. - Update
WithCalFormatter(date, time, loc)to accept a time-only format as its second parameter. - Add a
time_formatquery parameter to thecmd/gobl.htmlserver and wire it into rendering options.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/options.go | Refactors CalFormatter to separate date vs time formats and defines a shared date-time separator. |
| goblhtml.go | Updates the public option WithCalFormatter to accept a time-only format and apply it to internal options. |
| components/t/i18n.templ | Changes cal.DateTime localization to compose formatted date + separator + formatted time. |
| components/t/i18n_templ.go | Regenerates templ output to match the updated template/imports and new formatting logic. |
| cmd/gobl.html/serve.go | Adds time_format query param and passes it through to WithCalFormatter. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Agent-Logs-Url: https://github.com/invopop/gobl.html/sessions/3af9de49-a07b-49c2-b117-5e862329e523 Co-authored-by: methodofaction <[email protected]>
Agent-Logs-Url: https://github.com/invopop/gobl.html/sessions/5176fd6c-0d9a-4e59-9fe4-632a92eaf528 Co-authored-by: methodofaction <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes APP-472
Summary
CalFormatter.DateTimewith aTimefield.cal.DateTimerendering now composes<date format> · <time format>, so a user-supplieddate_formatalways applies — even when the document has an issue time.time_formatquery parameter to the CLI server, configured independently fromdate_format.Public API change
The second parameter of
goblhtml.WithCalFormatter(date, time, loc)is now a time-only template (e.g.15:04,3:04 PM) instead of a combined date-time template (e.g.2006-01-02 · 15:04). The only in-repo caller (cmd/gobl.html) passed"", so it is unaffected. External callers (notablypdf.go) will need to pass a time format instead of a combined template.Test plan
go build ./...go test ./...(defaults still produce identical output:2026-03-25 · 12:34)WithCalFormatter("02/01/2006", "", time.UTC)onco-dian-invoice.json(hasissue_date+issue_time) now outputs25/03/2026 · 12:34— bug fixedWithCalFormatter("02/01/2006", "3:04 PM", time.UTC)outputs25/03/2026 · 12:34 PM— independent time format confirmed🤖 Generated with Claude Code