Skip to content

Commit b2a98e2

Browse files
authored
fix(kilo-app): fix invalid date in earlybird billing banner (#1639)
2 parents affc50e + 5b8081c commit b2a98e2

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

kilo-app/AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ npx expo install --dev <package-name> # devDependencies
4343

4444
- When you need data from the backend, **always add a new tRPC procedure** rather than copying data or inventing client-side alternatives. The app uses tRPC with React Query — adding a procedure is cheap and keeps the source of truth on the server.
4545
- When a component takes backend data as props, derive the prop types from the tRPC router's return types (e.g., `NonNullable<ReturnType<typeof useMyQuery>['data']>`) instead of manually copying type definitions. This keeps types in sync with the backend automatically.
46-
- **Never use `new Date()` on timestamp strings from the backend.** Drizzle uses `mode: 'string'` for timestamps, and PostgreSQL's format (`2026-03-13 14:30:00+00`) is not parseable by Hermes. Use `parseTimestamp()` from `@/lib/utils` instead.
46+
- **Never use `new Date()` on any date or timestamp string from the backend.** Hermes cannot reliably parse PostgreSQL timestamps (`2026-03-13 14:30:00+00`) or date-only strings (`2026-09-26`). Always use `parseTimestamp()` from `@/lib/utils` — it handles both formats.
4747

4848
### Mutations
4949

kilo-app/src/lib/utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ function cn(...inputs: ClassValue[]) {
1111
* so we normalise the space separator to `T` before parsing.
1212
*/
1313
function parseTimestamp(value: string): Date {
14+
// Date-only: "2026-09-26" → treat as UTC midnight
15+
if (/^\d{4}-\d{2}-\d{2}$/.test(value)) {
16+
return new Date(`${value}T00:00:00Z`);
17+
}
1418
// PostgreSQL: "2026-03-16 15:21:40.957+00" → need "T" separator and full tz offset "+00:00"
1519
const iso = value.replace(' ', 'T').replace(/([+-]\d{2})$/, '$1:00');
1620
return new Date(iso);

0 commit comments

Comments
 (0)