aboutsummaryrefslogtreecommitdiffstats
path: root/models/webhook.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/webhook.go
parent0c9a616326ba096a2ff6c058cc96950f68c0fa6e (diff)
downloadgitea-ad513a20e939691828ba415c9a565e8ff3daa95f.tar.gz
gitea-ad513a20e939691828ba415c9a565e8ff3daa95f.zip
#2302 Replace time.Time with Unix Timestamp (int64)
Diffstat (limited to 'models/webhook.go')
-rw-r--r--models/webhook.go22
1 files changed, 18 insertions, 4 deletions
diff --git a/models/webhook.go b/models/webhook.go
index c20a72e97e..6d8b8c1682 100644
--- a/models/webhook.go
+++ b/models/webhook.go
@@ -94,8 +94,20 @@ type Webhook struct {
HookTaskType HookTaskType
Meta string `xorm:"TEXT"` // store hook-specific attributes
LastStatus HookStatus // Last delivery status
- Created time.Time `xorm:"CREATED"`
- Updated time.Time `xorm:"UPDATED"`
+
+ Created time.Time `xorm:"-"`
+ CreatedUnix int64
+ Updated time.Time `xorm:"-"`
+ UpdatedUnix int64
+}
+
+func (w *Webhook) BeforeInsert() {
+ w.CreatedUnix = time.Now().UTC().Unix()
+ w.UpdatedUnix = w.CreatedUnix
+}
+
+func (w *Webhook) BeforeUpdate() {
+ w.UpdatedUnix = time.Now().UTC().Unix()
}
func (w *Webhook) AfterSet(colName string, _ xorm.Cell) {
@@ -106,8 +118,10 @@ func (w *Webhook) AfterSet(colName string, _ xorm.Cell) {
if err = json.Unmarshal([]byte(w.Events), w.HookEvent); err != nil {
log.Error(3, "Unmarshal[%d]: %v", w.ID, err)
}
- case "created":
- w.Created = regulateTimeZone(w.Created)
+ case "created_unix":
+ w.Created = time.Unix(w.CreatedUnix, 0).Local()
+ case "updated_unix":
+ w.Updated = time.Unix(w.UpdatedUnix, 0).Local()
}
}