Files
Redflag/aggregator-server/internal/services/timezone.go
Fimeg a7fad61de2 Update installer system for update approval functionality
Major milestone: Update installation system now works
- Implemented unified installer interface with factory pattern
- Created APT, DNF, and Docker installers
- Integrated installer into agent command processing loop
- Update approval button now actually installs packages

Documentation updates:
- Updated claude.md with Session 7 implementation log
- Created clean, professional README.md for GitHub
- Added screenshots section with 4 dashboard views
- Preserved detailed development history in backup files

Repository ready for GitHub alpha release with working installer functionality.
2025-10-16 09:06:12 -04:00

58 lines
1.7 KiB
Go

package services
import (
"time"
"github.com/aggregator-project/aggregator-server/internal/config"
)
type TimezoneService struct {
config *config.Config
}
func NewTimezoneService(config *config.Config) *TimezoneService {
return &TimezoneService{
config: config,
}
}
// GetTimezoneLocation returns the configured timezone as a time.Location
func (s *TimezoneService) GetTimezoneLocation() (*time.Location, error) {
return time.LoadLocation(s.config.Timezone)
}
// FormatTimeForTimezone formats a time.Time according to the configured timezone
func (s *TimezoneService) FormatTimeForTimezone(t time.Time) (time.Time, error) {
loc, err := s.GetTimezoneLocation()
if err != nil {
return t, err
}
return t.In(loc), nil
}
// GetNowInTimezone returns the current time in the configured timezone
func (s *TimezoneService) GetNowInTimezone() (time.Time, error) {
return s.FormatTimeForTimezone(time.Now())
}
// GetAvailableTimezones returns a list of common timezones
func (s *TimezoneService) GetAvailableTimezones() []TimezoneOption {
return []TimezoneOption{
{Value: "UTC", Label: "UTC (Coordinated Universal Time)"},
{Value: "America/New_York", Label: "Eastern Time (ET)"},
{Value: "America/Chicago", Label: "Central Time (CT)"},
{Value: "America/Denver", Label: "Mountain Time (MT)"},
{Value: "America/Los_Angeles", Label: "Pacific Time (PT)"},
{Value: "Europe/London", Label: "London (GMT)"},
{Value: "Europe/Paris", Label: "Paris (CET)"},
{Value: "Europe/Berlin", Label: "Berlin (CET)"},
{Value: "Asia/Tokyo", Label: "Tokyo (JST)"},
{Value: "Asia/Shanghai", Label: "Shanghai (CST)"},
{Value: "Australia/Sydney", Label: "Sydney (AEDT)"},
}
}
type TimezoneOption struct {
Value string `json:"value"`
Label string `json:"label"`
}