feat: set timezone user level

This commit is contained in:
juancwu 2026-03-03 12:29:41 +00:00
commit 945069052f
11 changed files with 261 additions and 18 deletions

View file

@ -6,6 +6,20 @@ type Profile struct {
ID string `db:"id"`
UserID string `db:"user_id"`
Name string `db:"name"`
Timezone *string `db:"timezone"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
}
// Location returns the *time.Location for this profile's timezone.
// Returns UTC if timezone is nil or invalid.
func (p *Profile) Location() *time.Location {
if p.Timezone == nil || *p.Timezone == "" {
return time.UTC
}
loc, err := time.LoadLocation(*p.Timezone)
if err != nil {
return time.UTC
}
return loc
}