Skip to content

Commit 8c8eb60

Browse files
committed
fine tune comments
1 parent f333786 commit 8c8eb60

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

modules/util/sec_to_time.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,14 @@ import (
99
)
1010

1111
// SecToHours converts an amount of seconds to a human-readable hours string.
12-
// This is sutable for planning and managing timesheets.
12+
// This is stable for planning and managing timesheets.
13+
// Here it only supports hours and minutes, because a work day could contain 6 or 7 or 8 hours.
1314
func SecToHours(durationVal any) string {
1415
duration, _ := ToInt64(durationVal)
15-
16-
formattedTime := ""
17-
18-
// The following three variables are calculated without depending
19-
// on the previous calculated variables.
20-
hours := (duration / 3600)
16+
hours := duration / 3600
2117
minutes := (duration / 60) % 60
2218

19+
formattedTime := ""
2320
formattedTime = formatTime(hours, "hour", formattedTime)
2421
formattedTime = formatTime(minutes, "minute", formattedTime)
2522

@@ -37,6 +34,5 @@ func formatTime(value int64, name, formattedTime string) string {
3734
} else if value > 1 {
3835
formattedTime = fmt.Sprintf("%s%d %ss ", formattedTime, value, name)
3936
}
40-
4137
return formattedTime
4238
}

0 commit comments

Comments
 (0)