settings

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(projectName string, hourlyRate float64) error

func CreateWithTemplate

func CreateWithTemplate(projectName string, hourlyRate float64, description string, exportPath string) error

func FormatDate

func FormatDate(t time.Time) string

FormatDate formats t according to the user's configured date format. Defaults to "01/02/2006" (MM/DD/YYYY).

func FormatDateDashed

func FormatDateDashed(t time.Time) string

FormatDateDashed formats t using dashes between date components.

func FormatDateLong

func FormatDateLong(t time.Time) string

FormatDateLong returns a long human-readable date string like "Mon, Jan 2, 2006".

func FormatDateTime

func FormatDateTime(t time.Time) string

FormatDateTime returns the date and time formatted according to user preferences.

func FormatDateTimeDashed

func FormatDateTimeDashed(t time.Time) string

FormatDateTimeDashed returns the dashed date and time formatted according to user preferences.

func FormatDateTimeLong

func FormatDateTimeLong(t time.Time) string

FormatDateTimeLong returns a long human-readable date/time string honoring the user's time format preference.

func FormatTime

func FormatTime(t time.Time) string

FormatTime formats t according to the user's configured time format. Falls back to 12-hour format "3:04 PM".

func FormatTimePadded

func FormatTimePadded(t time.Time) string

FormatTimePadded formats t with a padded hour for 12-hour formats ("03:04 PM") or returns the 24-hour format when configured.

func GetDisplayTimezone added in v0.4.5

func GetDisplayTimezone() *time.Location

GetDisplayTimezone returns the user's configured timezone or the local timezone as a fallback.

func GetGlobalConfigPath

func GetGlobalConfigPath() (string, error)

GetGlobalConfigPath returns the path to the global config file. If the TMPO_DEV environment variable is set to 1 or true, a developer-specific config path is returned.

func GetProjectsPath added in v0.5.0

func GetProjectsPath() (string, error)

GetProjectsPath returns the path to the global projects registry file

func ToDisplayTime added in v0.5.3

func ToDisplayTime(t time.Time) time.Time

ToDisplayTime converts the provided time to the user's display timezone.

Types

type Config

type Config struct {
	ProjectName string  `yaml:"project_name"`
	HourlyRate  float64 `yaml:"hourly_rate,omitempty"`
	Description string  `yaml:"description,omitempty"`
	ExportPath  string  `yaml:"export_path,omitempty"`
}

IMPORTANT: When adding new fields to this struct, also update configTemplate below.

func FindAndLoad

func FindAndLoad() (*Config, string, error)

func Load

func Load(path string) (*Config, error)

func (*Config) Save

func (c *Config) Save(path string) error

type GlobalConfig

type GlobalConfig struct {
	Currency   string `yaml:"currency"`
	DateFormat string `yaml:"date_format,omitempty"`
	TimeFormat string `yaml:"time_format,omitempty"`
	Timezone   string `yaml:"timezone,omitempty"`
	ExportPath string `yaml:"export_path,omitempty"`
}

func DefaultGlobalConfig

func DefaultGlobalConfig() *GlobalConfig

func LoadGlobalConfig

func LoadGlobalConfig() (*GlobalConfig, error)

LoadGlobalConfig loads the global config from disk. If the config file does not exist the default config is returned.

func (*GlobalConfig) Save

func (gc *GlobalConfig) Save() error

Save writes the GlobalConfig to the config file, creating the config directory if necessary.

type GlobalProject added in v0.5.0

type GlobalProject struct {
	Name        string   `yaml:"name"`
	HourlyRate  *float64 `yaml:"hourly_rate,omitempty"`
	Description string   `yaml:"description,omitempty"`
	ExportPath  string   `yaml:"export_path,omitempty"`
}

GlobalProject represents a global project configuration

type ProjectsRegistry added in v0.5.0

type ProjectsRegistry struct {
	Projects []GlobalProject `yaml:"projects"`
}

ProjectsRegistry holds all global projects

func LoadProjects added in v0.5.0

func LoadProjects() (*ProjectsRegistry, error)

LoadProjects loads the global projects registry

func (*ProjectsRegistry) AddProject added in v0.5.0

func (pr *ProjectsRegistry) AddProject(project GlobalProject) error

AddProject adds a new project to the registry

func (*ProjectsRegistry) DeleteProject added in v0.5.0

func (pr *ProjectsRegistry) DeleteProject(name string) error

DeleteProject removes a project from the registry

func (*ProjectsRegistry) Exists added in v0.5.0

func (pr *ProjectsRegistry) Exists(name string) bool

Exists checks if a project exists in the registry (case-insensitive)

func (*ProjectsRegistry) GetProject added in v0.5.0

func (pr *ProjectsRegistry) GetProject(name string) (*GlobalProject, error)

GetProject retrieves a project by name

func (*ProjectsRegistry) ListProjects added in v0.5.0

func (pr *ProjectsRegistry) ListProjects() []GlobalProject

ListProjects returns all projects in the registry

func (*ProjectsRegistry) Save added in v0.5.0

func (pr *ProjectsRegistry) Save() error

Save saves the projects registry to disk

func (*ProjectsRegistry) UpdateProject added in v0.5.0

func (pr *ProjectsRegistry) UpdateProject(name string, updatedProject GlobalProject) error

UpdateProject updates an existing project in the registry

Jump to

Keyboard shortcuts

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