---
title: "spacetime: IANA time zones and hours in JavaScript | VulCode"
description: "In spacetime we fixed the hour setter clamping to 24, made whereIts() return properly cased zone names and exposed the tzdb version, in JavaScript."
url: "https://vulcode.com/en/opensource/contributions/spacetime"
lang: "en"
---

[All contributions](https://vulcode.com/en/opensource/contributions)

spencermountain/spacetime

# spacetime

A lightweight JavaScript library for working with dates and time zones.

[See the repository](https://github.com/spencermountain/spacetime) [All contributions](https://vulcode.com/en/opensource/contributions)

- **Language**: JavaScript
- **GitHub stars**: 4,104
- **Merged changes**: 3
- **Project site**: [spacetime.how](https://spacetime.how/)

## What we changed

Setting an hour of 24 or more now clamps to 23 instead of breaking the date, whereIts() returns zone names in the same casing as timezone().name, and the library exposes the tzdb version as spacetime.tzdbVersion.

### What this work shows

- IANA time zones and tzdb

- Off-by-one range errors

- Build-time generated data

- TypeScript typings for a JS library

What was broken

### hour(24) broke the whole date

The hour() setter clamped values of 24 and above to 24, an hour that does not exist. walkTo() rejected it and set epoch to null, so the object became invalid and format('iso') returned an empty string.

How we fixed it

### Clamped to 23

The upper bound in hours() is now 23, so hour(24), hour(25) and hour(100) give 23:00 on the same day, just as date(40) and month(13) clamp to the last valid value. A test in set.test.js also checks that negative hours still give 0.

[#467](https://github.com/spencermountain/spacetime/pull/467)

What was broken

### whereIts() returned lowercase names

whereIts() returned the raw data keys, such as antarctica/mawson, while timezone().name gave the same zones in proper IANA casing. The output of one could not be compared directly with the other.

How we fixed it

### A shared titleCase function

We moved titleCase into its own file and both functions use it, so whereIts() returns names such as Antarctica/Mawson and America/Port-au-Prince. A test compares every returned name with timezone().name.

[#474](https://github.com/spencermountain/spacetime/pull/474)

What was broken

### No time zone database version in the API

The library did not say which IANA tzdb release its zone data came from. Anyone who wanted to store that version next to their dates, in case the zones changed later, had nowhere to read it from.

How we fixed it

### A new spacetime.tzdbVersion field

The script that generates the zone data writes the tzdata version into the generated file, pack.js carries it through, and the library exposes it as spacetime.tzdbVersion, for example 2026c. We also added the type in constructors.d.ts and a test.

[#473](https://github.com/spencermountain/spacetime/pull/473)

## Merged changes 3

- [#474 Return titlecased timezone names from whereIts Merged 15 October 2026](https://github.com/spencermountain/spacetime/pull/474)

- [#473 Expose the tzdb version as spacetime.tzdbVersion Merged 15 October 2026](https://github.com/spencermountain/spacetime/pull/473)

- [#467 Fix hour() setter clamping to an invalid hour (24) Merged 8 September 2026](https://github.com/spencermountain/spacetime/pull/467)

## What it taught us

A date library breaks at three levels at once: a range boundary in a setter, IANA zone names in the public API, and the script that generates zone data. We fixed all three, so the tzdb version reaches the code and the typings.

[More about this technology: TypeScript, React and Node](https://vulcode.com/en/technologies/typescript-react-and-node)

## Other projects we write code for

- [**Material UI** JavaScript · 99,391 stars A React component library that implements Google's Material Design: ready-made text fields, selects, buttons and other interface elements.](https://vulcode.com/en/opensource/contributions/material-ui)

- [**Grafana** TypeScript · 78,050 stars An open observability and data visualisation platform that shows metrics, logs and traces from Prometheus, Loki, Elasticsearch, PostgreSQL and many other sources on dashboards.](https://vulcode.com/en/opensource/contributions/grafana)

- [**Marked** TypeScript · 37,323 stars A fast Markdown parser and compiler to HTML, written in TypeScript and following CommonMark and GitHub Flavored Markdown.](https://vulcode.com/en/opensource/contributions/marked)

- [**Autoprefixer** JavaScript · 22,197 stars A PostCSS plugin that adds browser prefixes to CSS based on Can I Use data, including the -ms-grid syntax for CSS Grid layouts.](https://vulcode.com/en/opensource/contributions/autoprefixer)

- [**Lichess** TypeScript · 19,013 stars The lichess.org chess server: free, ad-free and open source, focused on real-time play. The back end is written in Scala, the interface in TypeScript.](https://vulcode.com/en/opensource/contributions/lichess)

- [**compromise** JavaScript · 12,176 stars A natural language processing library in JavaScript: it splits text into sentences and words, tags parts of speech, conjugates verbs and inflects nouns, and reads dates through a plugin. It runs in the browser and in Node.js.](https://vulcode.com/en/opensource/contributions/compromise)

## Describe your project.

A free quote comes back within an hour during working hours.

### Rather skip the form?

Ask in the chat or write to us directly.

Open the chat

- **Email**: [hello@vulcode.com](mailto:hello@vulcode.com)
- **Phone**: [+48 576 043 920](tel:+48576043920)
- **Discord**: [discord.gg/vulcode](https://discord.gg/vulcode)
