String returns a human-readable representation of the TimeDelta
()
| 165 | |
| 166 | // String returns a human-readable representation of the TimeDelta |
| 167 | func (td *TimeDelta) String() string { |
| 168 | var parts []string |
| 169 | if td.Months > 0 { |
| 170 | parts = append(parts, fmt.Sprintf("%dmo", td.Months)) |
| 171 | } |
| 172 | if td.Weeks > 0 { |
| 173 | parts = append(parts, fmt.Sprintf("%dw", td.Weeks)) |
| 174 | } |
| 175 | if td.Days > 0 { |
| 176 | parts = append(parts, fmt.Sprintf("%dd", td.Days)) |
| 177 | } |
| 178 | if td.Hours > 0 { |
| 179 | parts = append(parts, fmt.Sprintf("%dh", td.Hours)) |
| 180 | } |
| 181 | if td.Minutes > 0 { |
| 182 | parts = append(parts, fmt.Sprintf("%dm", td.Minutes)) |
| 183 | } |
| 184 | if len(parts) == 0 { |
| 185 | return "0m" |
| 186 | } |
| 187 | return "+" + strings.Join(parts, "") |
| 188 | } |
| 189 | |
| 190 | // isRelativeStopTime checks if a stop-time value is a relative time delta |
| 191 | func isRelativeStopTime(stopTime string) bool { |
no outgoing calls