diff options
author | Unknwon <u@gogs.io> | 2016-03-09 19:53:30 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2016-03-09 19:53:30 -0500 |
commit | ad513a20e939691828ba415c9a565e8ff3daa95f (patch) | |
tree | c15aa2c82a5ed242ba51c837804f050690dd60ad /models/issue_comment.go | |
parent | 0c9a616326ba096a2ff6c058cc96950f68c0fa6e (diff) | |
download | gitea-ad513a20e939691828ba415c9a565e8ff3daa95f.tar.gz gitea-ad513a20e939691828ba415c9a565e8ff3daa95f.zip |
#2302 Replace time.Time with Unix Timestamp (int64)
Diffstat (limited to 'models/issue_comment.go')
-rw-r--r-- | models/issue_comment.go | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/models/issue_comment.go b/models/issue_comment.go index e63b39085b..ef890fd2fc 100644 --- a/models/issue_comment.go +++ b/models/issue_comment.go @@ -52,9 +52,11 @@ type Comment struct { IssueID int64 `xorm:"INDEX"` CommitID int64 Line int64 - Content string `xorm:"TEXT"` - RenderedContent string `xorm:"-"` - Created time.Time `xorm:"CREATED"` + Content string `xorm:"TEXT"` + RenderedContent string `xorm:"-"` + + Created time.Time `xorm:"-"` + CreatedUnix int64 // Reference issue in commit message CommitSHA string `xorm:"VARCHAR(40)"` @@ -65,6 +67,10 @@ type Comment struct { ShowTag CommentTag `xorm:"-"` } +func (c *Comment) BeforeInsert() { + c.CreatedUnix = time.Now().UTC().Unix() +} + func (c *Comment) AfterSet(colName string, _ xorm.Cell) { var err error switch colName { @@ -84,8 +90,8 @@ func (c *Comment) AfterSet(colName string, _ xorm.Cell) { log.Error(3, "GetUserByID[%d]: %v", c.ID, err) } } - case "created": - c.Created = regulateTimeZone(c.Created) + case "created_unix": + c.Created = time.Unix(c.CreatedUnix, 0).Local() } } |