summaryrefslogtreecommitdiffstats
path: root/models/login.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/login.go
parent0c9a616326ba096a2ff6c058cc96950f68c0fa6e (diff)
downloadgitea-ad513a20e939691828ba415c9a565e8ff3daa95f.tar.gz
gitea-ad513a20e939691828ba415c9a565e8ff3daa95f.zip
#2302 Replace time.Time with Unix Timestamp (int64)
Diffstat (limited to 'models/login.go')
-rw-r--r--models/login.go25
1 files changed, 23 insertions, 2 deletions
diff --git a/models/login.go b/models/login.go
index cbad646d1e..6ed4fefbdf 100644
--- a/models/login.go
+++ b/models/login.go
@@ -101,8 +101,20 @@ type LoginSource struct {
Name string `xorm:"UNIQUE"`
IsActived bool `xorm:"NOT NULL DEFAULT false"`
Cfg core.Conversion `xorm:"TEXT"`
- Created time.Time `xorm:"CREATED"`
- Updated time.Time `xorm:"UPDATED"`
+
+ Created time.Time `xorm:"-"`
+ CreatedUnix int64
+ Updated time.Time `xorm:"-"`
+ UpdatedUnix int64
+}
+
+func (s *LoginSource) BeforeInsert() {
+ s.CreatedUnix = time.Now().UTC().Unix()
+ s.UpdatedUnix = s.CreatedUnix
+}
+
+func (s *LoginSource) BeforeUpdate() {
+ s.UpdatedUnix = time.Now().UTC().Unix()
}
// Cell2Int64 converts a xorm.Cell type to int64,
@@ -132,6 +144,15 @@ func (source *LoginSource) BeforeSet(colName string, val xorm.Cell) {
}
}
+func (s *LoginSource) AfterSet(colName string, _ xorm.Cell) {
+ switch colName {
+ case "created_unix":
+ s.Created = time.Unix(s.CreatedUnix, 0).Local()
+ case "updated_unix":
+ s.Updated = time.Unix(s.UpdatedUnix, 0).Local()
+ }
+}
+
func (source *LoginSource) TypeName() string {
return LoginNames[source.Type]
}