summaryrefslogtreecommitdiffstats
path: root/models/admin.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2016-03-09 19:53:30 -0500
committerUnknwon <u@gogs.io>2016-03-09 19:53:30 -0500
commitad513a20e939691828ba415c9a565e8ff3daa95f (patch)
treec15aa2c82a5ed242ba51c837804f050690dd60ad /models/admin.go
parent0c9a616326ba096a2ff6c058cc96950f68c0fa6e (diff)
downloadgitea-ad513a20e939691828ba415c9a565e8ff3daa95f.tar.gz
gitea-ad513a20e939691828ba415c9a565e8ff3daa95f.zip
#2302 Replace time.Time with Unix Timestamp (int64)
Diffstat (limited to 'models/admin.go')
-rw-r--r--models/admin.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/models/admin.go b/models/admin.go
index 7756cd6ae2..d9e8e529ed 100644
--- a/models/admin.go
+++ b/models/admin.go
@@ -12,6 +12,7 @@ import (
"time"
"github.com/Unknwon/com"
+ "github.com/go-xorm/xorm"
"github.com/gogits/gogs/modules/base"
"github.com/gogits/gogs/modules/log"
@@ -29,7 +30,19 @@ type Notice struct {
ID int64 `xorm:"pk autoincr"`
Type NoticeType
Description string `xorm:"TEXT"`
- Created time.Time `xorm:"CREATED"`
+ Created time.Time `xorm:"-"`
+ CreatedUnix int64
+}
+
+func (n *Notice) BeforeInsert() {
+ n.CreatedUnix = time.Now().UTC().Unix()
+}
+
+func (n *Notice) AfterSet(colName string, _ xorm.Cell) {
+ switch colName {
+ case "created_unix":
+ n.Created = time.Unix(n.CreatedUnix, 0).Local()
+ }
}
// TrStr returns a translation format string.