fix(time): accept spaced durations and print whole-second times

tea time create 1 1h25m printed 2026-10-11T18:57:49.588823137Z while time
list printed whole seconds, and "1h 30m" or 2d failed with "duration
must be nonzero whole seconds". Durations may now contain spaces, and
errors name the problem: "invalid duration "2d": use h, m and s units
such as 1h25m". Tracked times are whole seconds everywhere.

Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
bircni committed 2026-10-12 00:14:52 +02:00
1 parent 1749d2f7f6
commit b5fecbde42
4 files changed
+54 -7

No files matched your search

+5 -1
View File
@@ -24,7 +24,11 @@ type TrackedTime struct {
// trackedTimeFrom falls back to repository when the record does not name its issue's repository.
func trackedTimeFrom(record *gitea.TrackedTime, repository string) TrackedTime {
result := TrackedTime{ID: record.ID, Seconds: record.Time, CreatedAt: timestamp(record.Created), User: record.UserName, Repository: repository}
result := TrackedTime{ID: record.ID, Seconds: record.Time, User: record.UserName, Repository: repository}
if !record.Created.IsZero() {
// Gitea returns the creation time of a new record with nanoseconds, but whole seconds in listings.
result.CreatedAt = record.Created.Format(time.RFC3339)
}
if record.Issue != nil {
result.IssueNumber = record.Issue.Index
result.IssueURL = record.Issue.HTMLURL