Skip to content

Commit 9377c1d

Browse files
committed
fix units
1 parent 5765fe9 commit 9377c1d

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

modules/util/time_str.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,19 @@ type timeStrGlobalVarsType struct {
1919
re *regexp.Regexp
2020
}
2121

22+
// When tracking working time, only hour/minute/second units are accurate and could be used.
23+
// For other units like "day", it depends on "how many working hours in a day: 6 or 7 or 8?
24+
// So at the moment, we only support hour/minute/second units.
25+
// In the future, it could be some configurable options to help users
26+
// to convert the working time to different units.
27+
2228
var timeStrGlobalVars = sync.OnceValue[*timeStrGlobalVarsType](func() *timeStrGlobalVarsType {
2329
v := &timeStrGlobalVarsType{}
2430
v.re = regexp.MustCompile(`(?i)(\d+)\s*([dhms])`)
2531
v.units = []struct {
2632
name string
2733
num int64
2834
}{
29-
{"d", 60 * 60 * 24},
3035
{"h", 60 * 60},
3136
{"m", 60},
3237
{"s", 1},

modules/util/time_str_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@ func TestTimeStr(t *testing.T) {
1717
output int64
1818
err bool
1919
}{
20-
{"1d", 86400, false},
2120
{"1h", 3600, false},
2221
{"1m", 60, false},
2322
{"1s", 1, false},
24-
{"1d 1h 1m 1s", 86400 + 3600 + 60 + 1, false},
23+
{"1h 1m 1s", 3600 + 60 + 1, false},
2524
{"1d1x", 0, true},
2625
}
2726
for _, test := range tests {
@@ -41,11 +40,10 @@ func TestTimeStr(t *testing.T) {
4140
input int64
4241
output string
4342
}{
44-
{86400, "1d"},
4543
{3600, "1h"},
4644
{60, "1m"},
4745
{1, "1s"},
48-
{86400 + 60 + 1, "1d 1m 1s"},
46+
{3600 + 1, "1h 1s"},
4947
}
5048
for _, test := range tests {
5149
t.Run(test.output, func(t *testing.T) {

options/locale/locale_en-US.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1677,7 +1677,7 @@ issues.timetracker_timer_stop = Stop timer
16771677
issues.timetracker_timer_discard = Discard timer
16781678
issues.timetracker_timer_manually_add = Add Time
16791679
1680-
issues.time_estimate_placeholder = 1d 2h 3m
1680+
issues.time_estimate_placeholder = 1h 2m
16811681
issues.time_estimate_set = Set estimated time
16821682
issues.time_estimate_display = Estimate: %s
16831683
issues.change_time_estimate_at = changed time estimate to <b>%s</b> %s

0 commit comments

Comments
 (0)