aboutsummaryrefslogtreecommitdiffstats
path: root/models/admin.go
diff options
context:
space:
mode:
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.