feat: set timezone user level
This commit is contained in:
parent
ad0989510a
commit
945069052f
11 changed files with 261 additions and 18 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue