Documentation
¶
Index ¶
- func Create(projectName string, hourlyRate float64) error
- func CreateWithTemplate(projectName string, hourlyRate float64, description string, exportPath string) error
- func FormatDate(t time.Time) string
- func FormatDateDashed(t time.Time) string
- func FormatDateLong(t time.Time) string
- func FormatDateTime(t time.Time) string
- func FormatDateTimeDashed(t time.Time) string
- func FormatDateTimeLong(t time.Time) string
- func FormatTime(t time.Time) string
- func FormatTimePadded(t time.Time) string
- func GetDisplayTimezone() *time.Location
- func GetGlobalConfigPath() (string, error)
- func GetProjectsPath() (string, error)
- func ToDisplayTime(t time.Time) time.Time
- type Config
- type GlobalConfig
- type GlobalProject
- type ProjectsRegistry
- func (pr *ProjectsRegistry) AddProject(project GlobalProject) error
- func (pr *ProjectsRegistry) DeleteProject(name string) error
- func (pr *ProjectsRegistry) Exists(name string) bool
- func (pr *ProjectsRegistry) GetProject(name string) (*GlobalProject, error)
- func (pr *ProjectsRegistry) ListProjects() []GlobalProject
- func (pr *ProjectsRegistry) Save() error
- func (pr *ProjectsRegistry) UpdateProject(name string, updatedProject GlobalProject) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateWithTemplate ¶
func FormatDate ¶
FormatDate formats t according to the user's configured date format. Defaults to "01/02/2006" (MM/DD/YYYY).
func FormatDateDashed ¶
FormatDateDashed formats t using dashes between date components.
func FormatDateLong ¶
FormatDateLong returns a long human-readable date string like "Mon, Jan 2, 2006".
func FormatDateTime ¶
FormatDateTime returns the date and time formatted according to user preferences.
func FormatDateTimeDashed ¶
FormatDateTimeDashed returns the dashed date and time formatted according to user preferences.
func FormatDateTimeLong ¶
FormatDateTimeLong returns a long human-readable date/time string honoring the user's time format preference.
func FormatTime ¶
FormatTime formats t according to the user's configured time format. Falls back to 12-hour format "3:04 PM".
func FormatTimePadded ¶
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
GetDisplayTimezone returns the user's configured timezone or the local timezone as a fallback.
func GetGlobalConfigPath ¶
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
GetProjectsPath returns the path to the global projects registry file
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 ¶
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