// TODO: I doubt we will see durations longer than days but in theory we should handle them
I doubt we will see durations longer than days but in theory we should handle them
// TODO : I doubt we will see durations longer than days but in theory we should handle them
func ConvertDuration(xmlDuration string) (duration time.Duration) {
	if "" != xmlDuration {
		subMatches := durationRegex.FindStringSubmatch(xmlDuration)
		if len(subMatches) == 3 {
			var hours int
			var nanoseconds time.Duration
			if "" != subMatches[1] {
				days, convErr := strconv.Atoi(subMatches[1])
				if nil == convErr {
					hours = 24 * days
				} else {
					log.Println(convErr)
				}
			}
			if "" != subMatches[2] {
				parsedDur, convErr := time.ParseDuration(strings.ToLower(subMatches[2]))
				if nil == convErr {
					nanoseconds = parsedDur
				} else {
					log.Println(convErr)
				}
			}
			duration = nanoseconds + time.Duration(hours)*time.Hour
		}
	}
	return duration
}
func ConvertDuration ( xmlDuration string ) ( duration time . Duration ) { if " " != xmlDuration { subMatches := durationRegex . FindStringSubmatch ( xmlDuration ) if len ( subMatches ) == 3 { var hours int var nanoseconds time . Duration if " " != subMatches [ 1 ] { days , convErr := strconv . Atoi ( subMatches [ 1 ] ) if nil == convErr { hours = 24 * days } else { log . Println ( convErr ) } } if " " != subMatches [ 2 ] { parsedDur , convErr := time . ParseDuration ( strings . ToLower ( subMatches [ 2 ] ) ) if nil == convErr { nanoseconds = parsedDur } else { log . Println ( convErr ) } } duration = nanoseconds + time . Duration ( hours ) * time . Hour } } return duration }
I doubt we will see durations longer than days but in theory we should handle them
I doubt we will see durations longer than days but in theory we should handle them