forked from go-gitea/gitea
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix incorrect webhook time and use relative-time to display it (go-gi…
…tea#24477) Fixes go-gitea#24414 After click replay this webhook, it will display `now`  --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Giteabot <teabot@gitea.io>
- Loading branch information
1 parent
4a722c9
commit dbb3736
Showing
5 changed files
with
57 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright 2017 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package timeutil | ||
|
||
import ( | ||
"time" | ||
|
||
"code.gitea.io/gitea/modules/setting" | ||
) | ||
|
||
// TimeStampNano is for nano time in database, do not use it unless there is a real requirement. | ||
type TimeStampNano int64 | ||
|
||
// TimeStampNanoNow returns now nano int64 | ||
func TimeStampNanoNow() TimeStampNano { | ||
return TimeStampNano(time.Now().UnixNano()) | ||
} | ||
|
||
// AsTime convert timestamp as time.Time in Local locale | ||
func (tsn TimeStampNano) AsTime() (tm time.Time) { | ||
return tsn.AsTimeInLocation(setting.DefaultUILocation) | ||
} | ||
|
||
// AsTimeInLocation convert timestamp as time.Time in Local locale | ||
func (tsn TimeStampNano) AsTimeInLocation(loc *time.Location) time.Time { | ||
return time.Unix(0, int64(tsn)).In(loc) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters