summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorNorwin <noerw@users.noreply.github.com>2021-01-21 14:51:52 +0000
committerGitHub <noreply@github.com>2021-01-21 15:51:52 +0100
commitb5570d3e680570343c1552bfc972b19b161209cd (patch)
tree548fbcdb9a760b47c54ac931c0180d87d08029d5 /models
parent56a89296050096df29d0a653019c194631cc6562 (diff)
downloadgitea-b5570d3e680570343c1552bfc972b19b161209cd.tar.gz
gitea-b5570d3e680570343c1552bfc972b19b161209cd.zip
Display current stopwatch in navbar (#14122)
* add notification about running stopwatch to header * serialize seconds, duration in stopwatches api * ajax update stopwatch i should get my testenv working locally... * new variant: hover dialog * noscript compatibility * js: live-update stopwatch time * js live update robustness
Diffstat (limited to 'models')
-rw-r--r--models/issue_stopwatch.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/models/issue_stopwatch.go b/models/issue_stopwatch.go
index 4b2bf1505d..a1c88503d8 100644
--- a/models/issue_stopwatch.go
+++ b/models/issue_stopwatch.go
@@ -19,6 +19,16 @@ type Stopwatch struct {
CreatedUnix timeutil.TimeStamp `xorm:"created"`
}
+// Seconds returns the amount of time passed since creation, based on local server time
+func (s Stopwatch) Seconds() int64 {
+ return int64(timeutil.TimeStampNow() - s.CreatedUnix)
+}
+
+// Duration returns a human-readable duration string based on local server time
+func (s Stopwatch) Duration() string {
+ return SecToTime(s.Seconds())
+}
+
func getStopwatch(e Engine, userID, issueID int64) (sw *Stopwatch, exists bool, err error) {
sw = new(Stopwatch)
exists, err = e.