Documentation
¶
Overview ¶
Package timezone provides an autocompletion predictor for IANA timezone identifiers and an optional standard library binding for *time.Location fields.
Timezones reads system zoneinfo tables (honoring $ZONEINFO when it names a directory) and falls back to a built-in identifier list; UTC is always included.
Mount RegisterLocation to register *time.Location with time.LoadLocation and enable IANA timezone completion on fields typed with the standard library type:
type CLI struct {
Zone conga.OptionalFlag[*time.Location] `help:"Server timezone"`
}
app := conga.New[CLI]().Use(timezone.RegisterLocation)
See https://docs.conga.sh/reference/domain-types/ for the domain type reference.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterLocation ¶
RegisterLocation mounts *time.Location support onto the app builder: the parser resolves IANA timezone identifiers with time.LoadLocation and completion offers the host's zones. Apply with app.Use.
Example ¶
RegisterLocation mounts *time.Location support: the flag accepts an IANA timezone identifier and completion offers the host's zones.
package main
import (
"context"
"fmt"
"time"
"github.com/conga-sh/conga"
"github.com/conga-sh/conga/timezone"
)
// CLI is an application whose flag accepts an IANA timezone identifier.
type CLI struct {
Zone conga.OptionalFlag[*time.Location] `help:"Server timezone"`
}
func (c *CLI) Run(_ context.Context, session *conga.Session) error {
_, err := fmt.Fprintln(session.Stdout(), c.Zone.Get())
return err
}
// RegisterLocation mounts *time.Location support: the flag accepts an IANA
// timezone identifier and completion offers the host's zones.
func main() {
app := conga.New[CLI]().
Use(timezone.RegisterLocation).
Args([]string{"--zone", "America/New_York"})
if err := app.Run(); err != nil {
panic(err)
}
}
Output: America/New_York
Types ¶
This section is empty.