diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2017-12-11 12:37:04 +0800 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2017-12-11 06:37:04 +0200 |
commit | f2e20c81b66e6a937ecdb686f8d1011371433365 (patch) | |
tree | 490e5af82aefdd25de5d90225b083ecb3ed11e5f /routers/api/v1/convert | |
parent | c082c3bce35d6d5d829a1e516b9bbf45b6d49bdc (diff) | |
download | gitea-f2e20c81b66e6a937ecdb686f8d1011371433365.tar.gz gitea-f2e20c81b66e6a937ecdb686f8d1011371433365.zip |
Refactor struct's time to remove unnecessary memory usage (#3142)
* refactor struct's time to remove unnecessary memory usage
* use AsTimePtr simple code
* fix tests
* fix time compare
* fix template on gpg
* use AddDuration instead of Add
Diffstat (limited to 'routers/api/v1/convert')
-rw-r--r-- | routers/api/v1/convert/convert.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/routers/api/v1/convert/convert.go b/routers/api/v1/convert/convert.go index b5aad95a9c..1bfd7f1ff0 100644 --- a/routers/api/v1/convert/convert.go +++ b/routers/api/v1/convert/convert.go @@ -82,7 +82,7 @@ func ToPublicKey(apiLink string, key *models.PublicKey) *api.PublicKey { URL: apiLink + com.ToStr(key.ID), Title: key.Name, Fingerprint: key.Fingerprint, - Created: key.Created, + Created: key.CreatedUnix.AsTime(), } } @@ -95,8 +95,8 @@ func ToGPGKey(key *models.GPGKey) *api.GPGKey { PrimaryKeyID: k.PrimaryKeyID, KeyID: k.KeyID, PublicKey: k.Content, - Created: k.Created, - Expires: k.Expired, + Created: k.CreatedUnix.AsTime(), + Expires: k.ExpiredUnix.AsTime(), CanSign: k.CanSign, CanEncryptComms: k.CanEncryptComms, CanEncryptStorage: k.CanEncryptStorage, @@ -112,8 +112,8 @@ func ToGPGKey(key *models.GPGKey) *api.GPGKey { PrimaryKeyID: key.PrimaryKeyID, KeyID: key.KeyID, PublicKey: key.Content, - Created: key.Created, - Expires: key.Expired, + Created: key.CreatedUnix.AsTime(), + Expires: key.ExpiredUnix.AsTime(), Emails: emails, SubsKey: subkeys, CanSign: key.CanSign, @@ -152,8 +152,8 @@ func ToHook(repoLink string, w *models.Webhook) *api.Hook { Active: w.IsActive, Config: config, Events: w.EventsArray(), - Updated: w.Updated, - Created: w.Created, + Updated: w.UpdatedUnix.AsTime(), + Created: w.CreatedUnix.AsTime(), } } |