timezone

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 12 Imported by: 0

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

func RegisterLocation[T any](app *conga.App[T])

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

func Timezones

func Timezones() predict.Predictor

Timezones configures completion of IANA timezone identifiers (e.g. UTC, America/New_York, Europe/London).

Types

This section is empty.

Jump to

Keyboard shortcuts

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