summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2017-12-14 07:45:31 +0800
committerGitHub <noreply@github.com>2017-12-14 07:45:31 +0800
commitf94c1b3943ebc4249e6240855c5414f735e8b25f (patch)
tree720895df7e78cd95e3803929332485b5619b611e /modules
parentb6d2243ac056be7997ef8d14be505873ce34a47e (diff)
downloadgitea-f94c1b3943ebc4249e6240855c5414f735e8b25f.tar.gz
gitea-f94c1b3943ebc4249e6240855c5414f735e8b25f.zip
Improvements for supporting UI Location (#3146)
* improvements for supporting UI Location * improved the comment
Diffstat (limited to 'modules')
-rw-r--r--modules/setting/setting.go3
-rw-r--r--modules/util/time_stamp.go10
2 files changed, 10 insertions, 3 deletions
diff --git a/modules/setting/setting.go b/modules/setting/setting.go
index 46ef20f61e..7d86ef3056 100644
--- a/modules/setting/setting.go
+++ b/modules/setting/setting.go
@@ -531,6 +531,9 @@ var (
IterateBufferSize int
ExternalMarkupParsers []MarkupParser
+ // UILocation is the location on the UI, so that we can display the time on UI.
+ // Currently only show the default time.Local, it could be added to app.ini after UI is ready
+ UILocation = time.Local
)
// DateLang transforms standard language locale name to corresponding value in datetime plugin.
diff --git a/modules/util/time_stamp.go b/modules/util/time_stamp.go
index 4a12a2cabe..a03560b24f 100644
--- a/modules/util/time_stamp.go
+++ b/modules/util/time_stamp.go
@@ -4,7 +4,11 @@
package util
-import "time"
+import (
+ "time"
+
+ "code.gitea.io/gitea/modules/setting"
+)
// TimeStamp defines a timestamp
type TimeStamp int64
@@ -31,13 +35,13 @@ func (ts TimeStamp) Year() int {
// AsTime convert timestamp as time.Time in Local locale
func (ts TimeStamp) AsTime() (tm time.Time) {
- tm = time.Unix(int64(ts), 0).Local()
+ tm = time.Unix(int64(ts), 0).In(setting.UILocation)
return
}
// AsTimePtr convert timestamp as *time.Time in Local locale
func (ts TimeStamp) AsTimePtr() *time.Time {
- tm := time.Unix(int64(ts), 0).Local()
+ tm := time.Unix(int64(ts), 0).In(setting.UILocation)
return &tm
}