in azkustodata/value/timespan.go [39:76]
func (t *Timespan) Marshal() string {
if t == nil || t.value == nil || *t.value/tick == 0 {
return "00:00:00"
}
// val is used to track the duration value as we move our parts of our time into our string format.
// For example, after we write to our string the number of days that value had, we remove those days
// from the duration. We continue doing this until val only holds values < 10 millionth of a second (tick)
// as that is the lowest precision in our string representation.
val := *t.value
var sb strings.Builder
// Add a - sign if we have a negative value. Convert our value to positive for easier processing.
if val < 0 {
sb.WriteString("-")
val = -val
}
// Only include the day if the duration is 1+ days.
days := val / day
if days > 0 {
sb.WriteString(fmt.Sprintf("%d.", days))
}
hours := (val % day) / time.Hour
minutes := (val % time.Hour) / time.Minute
seconds := (val % time.Minute) / time.Second
ticks := (val % time.Second) / tick
sb.WriteString(fmt.Sprintf("%02d:%02d:%02d", hours, minutes, seconds))
if ticks > 0 {
sb.WriteString(fmt.Sprintf(".%07d", ticks))
}
return sb.String()
}