summaryrefslogtreecommitdiffstats
path: root/models/user.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/user.go
parent0c9a616326ba096a2ff6c058cc96950f68c0fa6e (diff)
downloadgitea-ad513a20e939691828ba415c9a565e8ff3daa95f.tar.gz
gitea-ad513a20e939691828ba415c9a565e8ff3daa95f.zip
#2302 Replace time.Time with Unix Timestamp (int64)
Diffstat (limited to 'models/user.go')
-rw-r--r--models/user.go23
1 files changed, 17 insertions, 6 deletions
diff --git a/models/user.go b/models/user.go
index 14a05251a7..865178b4f5 100644
--- a/models/user.go
+++ b/models/user.go
@@ -68,10 +68,13 @@ type User struct {
Repos []*Repository `xorm:"-"`
Location string
Website string
- Rands string `xorm:"VARCHAR(10)"`
- Salt string `xorm:"VARCHAR(10)"`
- Created time.Time `xorm:"CREATED"`
- Updated time.Time `xorm:"UPDATED"`
+ Rands string `xorm:"VARCHAR(10)"`
+ Salt string `xorm:"VARCHAR(10)"`
+
+ Created time.Time `xorm:"-"`
+ CreatedUnix int64
+ Updated time.Time `xorm:"-"`
+ UpdatedUnix int64
// Remember visibility choice for convenience, true for private
LastRepoVisibility bool
@@ -103,18 +106,26 @@ type User struct {
Members []*User `xorm:"-"`
}
+func (u *User) BeforeInsert() {
+ u.CreatedUnix = time.Now().UTC().Unix()
+ u.UpdatedUnix = u.CreatedUnix
+}
+
func (u *User) BeforeUpdate() {
if u.MaxRepoCreation < -1 {
u.MaxRepoCreation = -1
}
+ u.UpdatedUnix = time.Now().UTC().Unix()
}
func (u *User) AfterSet(colName string, _ xorm.Cell) {
switch colName {
case "full_name":
u.FullName = markdown.Sanitizer.Sanitize(u.FullName)
- case "created":
- u.Created = regulateTimeZone(u.Created)
+ case "created_unix":
+ u.Created = time.Unix(u.CreatedUnix, 0).Local()
+ case "updated_unix":
+ u.Updated = time.Unix(u.UpdatedUnix, 0).Local()
}
}