print times in local timezone (#217)
dont resolve location ahead of time fixup! use local timezone for all printed times fixup! use local timezone for all printed times use local timezone for all printed times Co-authored-by: Norwin Roosen <git@nroo.de> Reviewed-on: https://gitea.com/gitea/tea/pulls/217 Reviewed-by: techknowlogick <techknowlogick@gitea.io> Reviewed-by: 6543 <6543@noreply.gitea.io>
This commit is contained in:
@@ -6,6 +6,7 @@ package print
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
// formatSize get kb in int and return string
|
||||
@@ -23,3 +24,12 @@ func formatSize(kb int64) string {
|
||||
}
|
||||
return fmt.Sprintf("%d Tb", gb/1024)
|
||||
}
|
||||
|
||||
// FormatTime give a date-time in local timezone if available
|
||||
func FormatTime(t time.Time) string {
|
||||
location, err := time.LoadLocation("Local")
|
||||
if err != nil {
|
||||
return t.Format("2006-01-02 15:04 UTC")
|
||||
}
|
||||
return t.In(location).Format("2006-01-02 15:04")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user