8000 Only calculate time for current record if it hasn't ended by dominikbraun · Pull Request #7 · dominikbraun/timetrace · GitHub
[go: up one dir, main page]

Skip to content

Only calculate time for current record if it hasn't ended - #7

Merged
dominikbraun merged 3 commits into
mainfrom
#4-status-use-end-time-for-stopped-records
May 14, 2021
Merged

dominikbraun merged 3 commits into
mainfrom
#4-status-use-end-time-for-stopped-records

Conversation

@dominikbraun
Copy link
Copy Markdown
Owner

Fixes #4. With this PR, the tracked time displayed with timetrace status is only calculcated using time.Now() if it hasn't ended.

@dominikbraun
dominikbraun commented May 14, 2021 •
Copy link
Copy Markdown
Owner Author

Also, if time isn't tracked at the moment of calling timetrace status, the returned current record and its tracked time will be nil:

timetrace/core/timetrace.go

Lines 100 to 110 in 265180e

report := &Report{
TrackedTimeToday: now.Sub(firstRecord.Start),
}
// If the latest record hasn't ended yet, it is the current record.
// Set information related to the current record.
if latestRecord.End == nil {
report.Current = latestRecord
trackedTimeCurrent := now.Sub(*latestRecord.End)
report.TrackedTimeCurrent = &trackedTimeCurrent
}

@dominikbraun
dominikbraun merged commit 6a7c114 into main May 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

timetrace status uses current time instead of end time for stopped records

1 participant

0