timezone

package
v0.0.0-...-63dd1cf Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package timezone provides system timezone management via timedatectl.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Darwin

type Darwin struct{}

Darwin implements the Provider interface for Darwin (macOS). All methods return ErrUnsupported as timedatectl timezone management is not available on macOS.

func NewDarwinProvider

func NewDarwinProvider() *Darwin

NewDarwinProvider factory to create a new Darwin instance.

func (*Darwin) Get

func (d *Darwin) Get(
	_ context.Context,
) (*Info, error)

Get returns ErrUnsupported on Darwin.

func (*Darwin) Update

func (d *Darwin) Update(
	_ context.Context,
	_ string,
) (*UpdateResult, error)

Update returns ErrUnsupported on Darwin.

type Debian

type Debian struct {
	provider.FactsAware
	// contains filtered or unexported fields
}

Debian implements the Provider interface for Debian-family systems using timedatectl for timezone management.

func NewDebianProvider

func NewDebianProvider(
	logger *slog.Logger,
	execManager exec.Manager,
) *Debian

NewDebianProvider factory to create a new Debian instance.

func (*Debian) Get

func (d *Debian) Get(
	_ context.Context,
) (*Info, error)

Get returns the current system timezone by running timedatectl and date.

func (*Debian) Update

func (d *Debian) Update(
	_ context.Context,
	timezone string,
) (*UpdateResult, error)

Update sets the system timezone via timedatectl. Idempotent: returns Changed false when the timezone already matches.

type Info

type Info struct {
	Timezone  string `json:"timezone"`
	UTCOffset string `json:"utc_offset,omitempty"`
}

Info represents the current timezone configuration.

type Linux

type Linux struct{}

Linux implements the Provider interface for generic Linux. All methods return ErrUnsupported as this is a generic Linux stub.

func NewLinuxProvider

func NewLinuxProvider() *Linux

NewLinuxProvider factory to create a new Linux instance.

func (*Linux) Get

func (l *Linux) Get(
	_ context.Context,
) (*Info, error)

Get returns ErrUnsupported on generic Linux.

func (*Linux) Update

func (l *Linux) Update(
	_ context.Context,
	_ string,
) (*UpdateResult, error)

Update returns ErrUnsupported on generic Linux.

type Provider

type Provider interface {
	// Get returns the current system timezone.
	Get(ctx context.Context) (*Info, error)
	// Update sets the system timezone. Idempotent.
	Update(ctx context.Context, tz string) (*UpdateResult, error)
}

Provider implements the methods to manage the system timezone.

type UpdateResult

type UpdateResult struct {
	Timezone string `json:"timezone"`
	Changed  bool   `json:"changed"`
	Error    string `json:"error,omitempty"`
}

UpdateResult represents the outcome of a timezone update.

Directories

Path Synopsis
Package mocks provides mock implementations for testing.
Package mocks provides mock implementations for testing.

Jump to

Keyboard shortcuts

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