1
1
mirror of https://github.com/go-gitea/gitea synced 2025-11-03 04:48:25 +00:00

feat: calculate duration

This commit is contained in:
Jason Song
2023-01-05 16:19:08 +08:00
parent c510fdbcf1
commit a4b2cf2426
8 changed files with 82 additions and 39 deletions

View File

@@ -27,15 +27,8 @@ type ActionTaskStep struct {
Updated timeutil.TimeStamp `xorm:"updated"`
}
func (step *ActionTaskStep) TakeTime() time.Duration {
if step.Started == 0 {
return 0
}
started := step.Started.AsTime()
if step.Status.IsDone() {
return step.Stopped.AsTime().Sub(started)
}
return time.Since(started).Truncate(time.Second)
func (step *ActionTaskStep) Duration() time.Duration {
return calculateDuration(step.Started, step.Stopped, step.Status)
}
func init() {