FixedDuration returns the given duration as a string of fixed length.
(d time.Duration)
| 723 | |
| 724 | // FixedDuration returns the given duration as a string of fixed length. |
| 725 | func FixedDuration(d time.Duration) string { |
| 726 | str := fmt.Sprintf("%02ds", int(d.Seconds())%60) |
| 727 | if d >= time.Minute { |
| 728 | str = fmt.Sprintf("%02dm", int(d.Minutes())%60) + str |
| 729 | } |
| 730 | if d >= time.Hour { |
| 731 | str = fmt.Sprintf("%02dh", int(d.Hours())) + str |
| 732 | } |
| 733 | return str |
| 734 | } |
| 735 | |
| 736 | // PageRange returns start and end indices given pagination params. Note that n |
| 737 | // is the size of the input list. |
no outgoing calls
no test coverage detected