kataras/iris · error

error parsing offset minutes: %s: %w

Error message

error parsing offset minutes: %s: %w

What it means

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.

Source

Thrown at x/jsonx/iso8601.go:246

	offset = offset[1:]

	offsetParts := strings.Split(offset, ":")
	if len(offsetParts) != 3 {
		return time.Time{}, fmt.Errorf("invalid offset format: %s", offset)
	}

	hours, err := strconv.Atoi(offsetParts[0])
	if err != nil {
		return time.Time{}, fmt.Errorf("error parsing offset hours: %s: %w", offset, err)
	}

	if hours > 24 {
		return time.Time{}, fmt.Errorf("invalid offset hours: %d: %s", hours, offset)
	}

	minutes, err := strconv.Atoi(offsetParts[1])
	if err != nil {
		return time.Time{}, fmt.Errorf("error parsing offset minutes: %s: %w", offset, err)
	}
	if minutes > 60 {
		return time.Time{}, fmt.Errorf("invalid offset minutes: %d: %s", minutes, offset)
	}

	seconds, err := strconv.Atoi(offsetParts[2])
	if err != nil {
		return time.Time{}, fmt.Errorf("error parsing offset seconds: %s: %w", offset, err)
	}

	if seconds > 60 {
		return time.Time{}, fmt.Errorf("invalid offset seconds: %d: %s", seconds, offset)
	}

	totalOffset := time.Duration(sign) * (time.Duration(hours)*time.Hour + time.Duration(minutes)*time.Minute + time.Duration(seconds)*time.Second)
	return t.Add(-totalOffset), nil
}

View on GitHub (pinned to 7bedaf55a0)

Solutions

  1. Fix the offset so the minutes field is plain ASCII digits (e.g. '+03:30:00').
  2. Strip stray characters and ensure the offset uses exactly two-digit numeric fields separated by ':'.
  3. Regenerate timestamps at the source with time.Format(time.RFC3339).

Example fix

// before
ParseISO8601("2024-01-02T15:04:05+03:1x:00") // error parsing offset minutes
// after
ParseISO8601("2024-01-02T15:04:05+03:30:00")
Defensive patterns

Strategy: validation

Validate before calling

func offsetMinutesNumeric(ts string) bool {
	i := strings.LastIndexAny(ts, "+-")
	if i < 0 { return false }
	parts := strings.Split(ts[i+1:], ":")
	if len(parts) != 3 { return false }
	_, err := strconv.Atoi(parts[1])
	return err == nil
}

Try / catch

tt, err := jsonx.ParseISO8601(s)
if err != nil {
	if strings.Contains(err.Error(), "error parsing offset minutes") {
		return fmt.Errorf("malformed timestamp %q: %w", s, err)
	}
	return err
}

Prevention

When it happens

Trigger: ParseISO8601 on a timestamp whose offset minutes field contains non-digits, e.g. '+03:1x:00' or '+03::00'.

Common situations: Hand-edited timestamps; truncated strings from fixed-width slicing; locale-formatted offsets with non-ASCII digits.

Related errors


AI-assisted analysis of kataras/iris@7bedaf55a0 (2026-08-30). Data as JSON: /api/errors/3a99e886fca87181. Report an issue: GitHub.