{"record":{"id":"2127a756cee33d73","repo":"kataras/iris","slug":"error-parsing-offset-seconds-s-w","errorCode":null,"errorMessage":"error parsing offset seconds: %s: %w","messagePattern":"error parsing offset seconds: (.+?): %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"x/jsonx/iso8601.go","lineNumber":254,"sourceCode":"\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\n// UnmarshalJSON parses the \"b\" into ISO8601 time.\nfunc (t *ISO8601) UnmarshalJSON(b []byte) error {\n\tif len(b) == 0 {\n\t\treturn nil\n\t}\n\n\ts := strings.Trim(string(b), `\"`)\n\ttt, err := ParseISO8601(s)","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/kataras/iris/blob/7bedaf55a0b64bbb2248a5845a2c60d81a30996a/x/jsonx/iso8601.go#L236-L272","documentation":"While parsing an unconventional '+HH:MM:SS' offset, adjustForUnconventionalOffset converts the seconds field with strconv.Atoi. This error wraps the strconv failure: the seconds 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 seconds field contains non-digits, e.g. '+03:30:0z' or a truncated '+03:30:' tail.","commonSituations":"Hand-edited or truncated timestamps; offsets coming from string-slicing code that drops characters; non-ASCII digits from locale-aware formatting.","solutions":["Fix the offset so the seconds field is plain ASCII digits (e.g. '+03:30:00').","Ensure the offset has three complete two-digit numeric fields; regenerate if truncated.","Produce standard RFC3339 timestamps (which need no seconds in the offset) at the source."],"exampleFix":"// before\nParseISO8601(\"2024-01-02T15:04:05+03:30:0z\") // error parsing offset seconds\n// after\nParseISO8601(\"2024-01-02T15:04:05+03:30:00\")","handlingStrategy":"validation","validationCode":"func offsetSecondsNumeric(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[2])\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 seconds\") {\n\t\treturn fmt.Errorf(\"malformed timestamp %q: %w\", s, err)\n\t}\n\treturn err\n}","preventionTips":["Ensure offsets contain complete three-part fields; reject truncated strings.","Strip non-ASCII digits at the boundary.","Use RFC3339 (offset without seconds) at the producer."],"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"}