Documentation
¶
Overview ¶
Package sitetime holds the site's time zone (entity.SiteInformation.Timezone): dates are stored in UTC and shown in this zone. Set at startup and whenever the setting is saved; UTC until then.
Index ¶
- Variables
- func ForUser(name string) *time.Location
- func Format(t time.Time, layout string) string
- func FromContext(ctx context.Context) *time.Location
- func In(t time.Time) time.Time
- func IsSite(loc *time.Location) bool
- func Load(name string) (*time.Location, error)
- func Location() *time.Location
- func Now() time.Time
- func Set(name string) error
- func SetUserZones(on bool)
- func UserZonesEnabled() bool
- func WithLocation(ctx context.Context, loc *time.Location) context.Context
- type ZoneOption
Constants ¶
This section is empty.
Variables ¶
var Zones = append([]string{"UTC"}, zones...)
Zones - the time zones offered in the site and user settings: UTC, then every canonical IANA zone of the world's regions (zones_gen.go). A stored zone outside the list is offered too (ZoneOptions).
Functions ¶
func ForUser ¶
ForUser - the time zone to show a user's pages in: their own (name) when user time zones are on and name is a valid zone, else the site's.
func FromContext ¶
FromContext - the request's time zone (WithLocation), else the site's.
func Load ¶
Load - the zone named name; an empty name is invalid (unlike time.LoadLocation, which reads it as UTC).
func Set ¶
Set makes name (an IANA zone like "Europe/Moscow") the site's time zone; an empty or unknown name is an error and changes nothing.
func UserZonesEnabled ¶
func UserZonesEnabled() bool
UserZonesEnabled - whether users may set their own time zone.
Types ¶
type ZoneOption ¶
ZoneOption - a zone for a select: Group - its region ("Europe", "America"…; "" for UTC), for an <optgroup>; Label - the rest of its name, readable, with its current UTC offset ("Buenos Aires, Argentina (UTC-3)" in "America"; "UTC").
func ZoneOptions ¶
func ZoneOptions(current string) []ZoneOption
ZoneOptions - Zones (plus current when it is outside them), grouped by region, labelled by place and current offset.
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
zonesgen
command
Command zonesgen writes pkg/sitetime/zones_gen.go - the canonical IANA time zones (the tz database's Zone entries, not its Link aliases) of the world's regions, from a tzdata.zi file (default /usr/share/zoneinfo/tzdata.zi).
|
Command zonesgen writes pkg/sitetime/zones_gen.go - the canonical IANA time zones (the tz database's Zone entries, not its Link aliases) of the world's regions, from a tzdata.zi file (default /usr/share/zoneinfo/tzdata.zi). |