jackc/pgx · error

cannot decode %v into Time

Error message

cannot decode %v into Time

What it means

Error "cannot decode %v into Time" thrown in jackc/pgx.

Source

Thrown at pgtype/time.go:217

		return err
	}

	return ts.ScanText(Text{String: string(buf), Valid: true})
}

type scanPlanTextAnyToTimeScanner struct{}

func (scanPlanTextAnyToTimeScanner) Scan(src []byte, dst any) error {
	scanner := (dst).(TimeScanner)

	if src == nil {
		return scanner.ScanTime(Time{})
	}

	s := string(src)

	if len(s) < 8 || s[2] != ':' || s[5] != ':' {
		return fmt.Errorf("cannot decode %v into Time", s)
	}

	hours, err := strconv.ParseInt(s[0:2], 10, 64)
	if err != nil {
		return fmt.Errorf("cannot decode %v into Time", s)
	}
	usec := hours * microsecondsPerHour

	minutes, err := strconv.ParseInt(s[3:5], 10, 64)
	if err != nil {
		return fmt.Errorf("cannot decode %v into Time", s)
	}
	usec += minutes * microsecondsPerMinute

	seconds, err := strconv.ParseInt(s[6:8], 10, 64)
	if err != nil {
		return fmt.Errorf("cannot decode %v into Time", s)
	}

View on GitHub (pinned to ec1a0befd2)

When it happens

Trigger: Thrown at pgtype/time.go:217 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of jackc/pgx@ec1a0befd2 (2026-08-04). Data as JSON: /data/errors/e453561620142fce.json. Report an issue: GitHub.