{"id":"d2a046b565cc3b70","repo":"jackc/pgx","slug":"d-microseconds-cannot-be-represented-as-time-time","errorCode":null,"errorMessage":"%d microseconds cannot be represented as time.Time","messagePattern":"(.+?) microseconds cannot be represented as time\\.Time","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgtype/builtin_wrappers.go","lineNumber":474,"sourceCode":"\t\treturn fmt.Errorf(\"cannot scan -Infinity into *time.Time\")\n\tdefault:\n\t\treturn fmt.Errorf(\"invalid InfinityModifier: %v\", v.InfinityModifier)\n\t}\n}\n\nfunc (w timeWrapper) TimestamptzValue() (Timestamptz, error) {\n\treturn Timestamptz{Time: time.Time(w), Valid: true}, nil\n}\n\nfunc (w *timeWrapper) ScanTime(v Time) error {\n\tif !v.Valid {\n\t\treturn fmt.Errorf(\"cannot scan NULL into *time.Time\")\n\t}\n\n\t// 24:00:00 is max allowed time in PostgreSQL, but time.Time will normalize that to 00:00:00 the next day.\n\tvar maxRepresentableByTime int64 = 24*60*60*1000000 - 1\n\tif v.Microseconds > maxRepresentableByTime {\n\t\treturn fmt.Errorf(\"%d microseconds cannot be represented as time.Time\", v.Microseconds)\n\t}\n\n\tusec := v.Microseconds\n\thours := usec / microsecondsPerHour\n\tusec -= hours * microsecondsPerHour\n\tminutes := usec / microsecondsPerMinute\n\tusec -= minutes * microsecondsPerMinute\n\tseconds := usec / microsecondsPerSecond\n\tusec -= seconds * microsecondsPerSecond\n\tns := usec * 1000\n\t*w = timeWrapper(time.Date(2000, 1, 1, int(hours), int(minutes), int(seconds), int(ns), time.UTC))\n\treturn nil\n}\n\nfunc (w timeWrapper) TimeValue() (Time, error) {\n\tt := time.Time(w)\n\tusec := int64(t.Hour())*microsecondsPerHour +\n\t\tint64(t.Minute())*microsecondsPerMinute +","sourceCodeStart":456,"sourceCodeEnd":492,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgtype/builtin_wrappers.go#L456-L492","documentation":"Error \"%d microseconds cannot be represented as time.Time\" thrown in jackc/pgx.","triggerScenarios":"Thrown at pgtype/builtin_wrappers.go:474 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"ec1a0befd22592cffffdeeb0a50311b506372f4c","analyzedAt":"2026-08-04T22:52:11.263Z","schemaVersion":2}