Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Neon 2 min read How-to mediumAdept

Fixing JavaScript Timezone Issues

A parking booking app stored Italian users' midnight bookings as 6:00 PM the previous day in a US-hosted Postgres database, because `new Date(selectedDate)` attached the browser's local timezone before the value reached the API. The fix was to build a plain `YYYY-MM-DD HH:MM:SS` string with no timezone information and store it directly, so the database keeps exactly the wall-clock time the user picked. The post ends with a short endorsement of Neon's free plan and easy connectivity.

Related posts

  • Building On-call: Time, timezones, and scheduling

    incident.io mediumAdept

    incident.io's on-call scheduler computes who is on shift from rotations with working hours, round-robin handovers and overrides, and getting it right depends on being precise about local time, offsets, IANA timezones, instants and durations. The design keeps everything as UTC instants (Postgres timestamptz, Go's time package) and converts to wall-clock time only at the edges or in isolated, well-tested calculations such as working hours. Users wanted schedules shown in their own timezone, and sometimes several at once, rather than the schedule's timezone. Correctness rests on unit-tested building blocks, JSON snapshot tests of schedule evaluations flagged in PRs via danger.js, and a periodic runtime audit job that re-evaluates active schedules against the cached on-call state.

  • Bun v0.6.13

    Bun mediumAdept

    Bun v0.6.13 adds Date mocking in bun test via setSystemTime, which affects Date.now(), new Date() and Intl.DateTimeFormat without mutating the Date object as Jest does. Buffer.toString("base64") is 10x faster, and node:tls and node:net fixes make the postgres package work over TLS and let nodemailer send mail. HTTP requests use 8 fewer bytes each because their boolean fields now live in a Zig packed struct. The release also fixes WebSocket zero-length messages and initial-payload ordering races, adds isUtf8/isAscii, and corrects Buffer.toString overloads, workspace: dependencies and empty env vars.

  • psql from the browser

    Neon easyNovice

    psql.sh is a browser-based emulation of Postgres's psql client, built on Neon's WebSocket proxy and serverless driver because browsers can't open raw TCP connections. Each session gets a fresh, isolated database by creating a child branch from a template branch, which yields a connection string almost instantly. Slash commands like \d reuse the Neon SQL Editor's library. The terminal UI was built from scratch instead of using xterm.js, since only a psql session needs emulating. The project is open source.

  • Parsing JSON from Postgres in JS? Don’t get the wrong number

    Neon mediumAdept

    JavaScript's JSON.parse() silently corrupts Postgres bigint and numeric values beyond Number.MAX_SAFE_INTEGER, so a row id can quietly become a different id. The fix is a custom JSON parser registered with node-postgres or Neon's serverless driver; the reviver argument can't help because numbers are already float64 by then. json-custom-numbers is introduced as a drop-in replacement that matches JSON.parse() on the JSON Parsing Test Suite, supports custom number parsing, and runs only 1.5–3× slower than native, versus 4–11× for lossless-json and json-bigint. Lessons from optimizing it: sticky RegExps for primitives, manual inlining, charCodeAt over charAt, a non-recursive state machine to avoid stack overflows, and how JIT warm-up and deoptimization from invalid inputs skew benchmarks.

  • Bringing psql’s \d to your web browser

    Neon mediumAdept

    Neon's web SQL Editor now supports psql backslash introspection commands like \d, \l, \dx and \sf, which live in psql's C client code rather than the Postgres server. Instead of compiling psql to WASM with emscripten, the C was translated to JavaScript via RegExp search-and-replace, reimplementations of helpers like sprintf, and a test script comparing output against real psql until every command matched; most fixes involved pointer arithmetic. Because backslash commands must be handled separately, SQL is now split client-side with a small open-source lexer using sticky RegExps that understands quoted identifiers, nested comments, escape and dollar-quoted strings, so only significant semicolons terminate statements.

The quest for software engineering knowledge.

Look:
Layout: