datefmt

package
v1.1.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 23, 2026 License: MPL-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package datefmt writes dates in the language they are being read in.

Go's time package formats month and day names in English only, so {{.PublishedAt.Format "January 2, 2006"}} on a French page reads "July 30, 2026" — the one English string on an otherwise translated page. This package holds the small amount of knowledge needed to avoid that: how each language the CMS knows orders a date, and what it calls the months.

It covers the languages the CMS itself is translated into (English and French, matching the admin UI) and falls back to English formatting for any other locale, which is the same behaviour a host gets today. A site running in a language that isn't here formats its own dates in its own templates, as it always could.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Long

func Long(t time.Time, locale string) string

Long writes a date the way a sentence would: "July 30, 2026" in English, "30 juillet 2026" in French. It is what a post's date line wants, and what {{cmsDate}} renders.

The first of the month is "1er juillet" in French — the one ordinal French uses in a date, and the reason this is not a format string.

func Short

func Short(t time.Time, locale string) string

Short writes the same date with the month abbreviated: "Jul 30, 2026", "30 juil. 2026". It is for lists and tables, where the full month name costs a column its width.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL