Skip to content

Template functions for dates and times - #27

Merged
tuzzmaniandevil merged 1 commit into
devfrom
feat/template-dates
Oct 8, 2026
Merged

tuzzmaniandevil merged 1 commit into
devfrom
feat/template-dates

Conversation

@tuzzmaniandevil

Copy link
Copy Markdown
Contributor

For #25. Ports OwlShack's now and date template functions.

  • {{date now "15:04"}}, {{date now "Mon 2 Jan, 3:04PM" "Pacific/Auckland"}}, {{now.Year}}.
  • {{date .Timestamp "15:04"}} renders a channel message's wire timestamp (uint32 unix seconds), which is what the issue asked for. Zero renders as year 0001, not 1970.
  • time/tzdata is embedded so a named zone resolves on Windows and minimal containers; TestEmbeddedTZDataIsLinked guards the import.
  • OwlShack's *time.Time case is left out (it exists for its RSS feed items).

Testing: OwlShack's seven tests, ported. Mutation-checked: dropping the tzdata import and ignoring the zone argument each fail them. Full suite under -race. Not run on air.

The optional formatPathBytes separator follows in a separate PR.

Ported from OwlShack. date formats a time.Time or the wire's unix seconds
in a Go layout, optionally in a named IANA zone; zero stays zero rather
than becoming 1970. time/tzdata is embedded so named zones resolve on
every release target, and a test guards the import.
@tuzzmaniandevil
tuzzmaniandevil merged commit f767bb5 into dev Oct 8, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant