Added keyboard shortcuts for post editing.
This commit is contained in:
parent
4f7058bf36
commit
44d35c6ccb
13 changed files with 215 additions and 28 deletions
|
|
@ -1,7 +1,31 @@
|
|||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
type User struct {
|
||||
ID int64
|
||||
Username string
|
||||
PasswordHashed []byte
|
||||
TimeZone string
|
||||
}
|
||||
|
||||
func (u User) FormatTime(t time.Time) string {
|
||||
if loc := getLocation(u.TimeZone); loc != nil {
|
||||
return t.In(loc).Format("2006-01-02 15:04:05")
|
||||
}
|
||||
return t.Format("2006-01-02 15:04:05")
|
||||
}
|
||||
|
||||
var loadedLocation = map[string]*time.Location{}
|
||||
|
||||
func getLocation(tz string) *time.Location {
|
||||
if loc, ok := loadedLocation[tz]; ok {
|
||||
return loc
|
||||
}
|
||||
loc, err := time.LoadLocation(tz)
|
||||
if err != nil {
|
||||
loc = time.Local
|
||||
}
|
||||
loadedLocation[tz] = loc
|
||||
return loc
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue