{"record":{"id":"3a99e886fca87181","repo":"kataras/iris","slug":"error-parsing-offset-minutes-s-w","errorCode":null,"errorMessage":"error parsing offset minutes: %s: %w","messagePattern":"error parsing offset minutes: (.+?): %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"x/jsonx/iso8601.go","lineNumber":246,"sourceCode":"\toffset = offset[1:]\n\n\toffsetParts := strings.Split(offset, \":\")\n\tif len(offsetParts) != 3 {\n\t\treturn time.Time{}, fmt.Errorf(\"invalid offset format: %s\", offset)\n\t}\n\n\thours, err := strconv.Atoi(offsetParts[0])\n\tif err != nil {\n\t\treturn time.Time{}, fmt.Errorf(\"error parsing offset hours: %s: %w\", offset, err)\n\t}\n\n\tif hours > 24 {\n\t\treturn time.Time{}, fmt.Errorf(\"invalid offset hours: %d: %s\", hours, offset)\n\t}\n\n\tminutes, err := strconv.Atoi(offsetParts[1])\n\tif err != nil {\n\t\treturn time.Time{}, fmt.Errorf(\"error parsing offset minutes: %s: %w\", offset, err)\n\t}\n\tif minutes > 60 {\n\t\treturn time.Time{}, fmt.Errorf(\"invalid offset minutes: %d: %s\", minutes, offset)\n\t}\n\n\tseconds, err := strconv.Atoi(offsetParts[2])\n\tif err != nil {\n\t\treturn time.Time{}, fmt.Errorf(\"error parsing offset seconds: %s: %w\", offset, err)\n\t}\n\n\tif seconds > 60 {\n\t\treturn time.Time{}, fmt.Errorf(\"invalid offset seconds: %d: %s\", seconds, offset)\n\t}\n\n\ttotalOffset := time.Duration(sign) * (time.Duration(hours)*time.Hour + time.Duration(minutes)*time.Minute + time.Duration(seconds)*time.Second)\n\treturn t.Add(-totalOffset), nil\n}\n","sourceCodeStart":228,"sourceCodeEnd":264,"githubUrl":"https://github.com/kataras/iris/blob/7bedaf55a0b64bbb2248a5845a2c60d81a30996a/x/jsonx/iso8601.go#L228-L264","documentation":"While parsing an unconventional '+HH:MM:SS' offset, adjustForUnconventionalOffset converts the minutes field with strconv.Atoi. This error wraps the strconv failure: the minutes portion of the offset was not a plain integer. The offset string is included and the strconv error is wrapped with %w.","triggerScenarios":"ParseISO8601 on a timestamp whose offset minutes field contains non-digits, e.g. '+03:1x:00' or '+03::00'.","commonSituations":"Hand-edited timestamps; truncated strings from fixed-width slicing; locale-formatted offsets with non-ASCII digits.","solutions":["Fix the offset so the minutes field is plain ASCII digits (e.g. '+03:30:00').","Strip stray characters and ensure the offset uses exactly two-digit numeric fields separated by ':'.","Regenerate timestamps at the source with time.Format(time.RFC3339)."],"exampleFix":"// before\nParseISO8601(\"2024-01-02T15:04:05+03:1x:00\") // error parsing offset minutes\n// after\nParseISO8601(\"2024-01-02T15:04:05+03:30:00\")","handlingStrategy":"validation","validationCode":"func offsetMinutesNumeric(ts string) bool {\n\ti := strings.LastIndexAny(ts, \"+-\")\n\tif i < 0 { return false }\n\tparts := strings.Split(ts[i+1:], \":\")\n\tif len(parts) != 3 { return false }\n\t_, err := strconv.Atoi(parts[1])\n\treturn err == nil\n}","typeGuard":null,"tryCatchPattern":"tt, err := jsonx.ParseISO8601(s)\nif err != nil {\n\tif strings.Contains(err.Error(), \"error parsing offset minutes\") {\n\t\treturn fmt.Errorf(\"malformed timestamp %q: %w\", s, err)\n\t}\n\treturn err\n}","preventionTips":["Require two-digit numeric minute fields in offsets.","Validate offsets with a strict regex before parsing.","Use RFC3339 timestamps from producers."],"tags":["time-parsing","iso8601","timezone-offset","strconv"],"backgroundTag":"invalid-timezone-offset-format","analyzedSha":"7bedaf55a0b64bbb2248a5845a2c60d81a30996a","analyzedAt":"2026-08-30T20:38:16.250Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}