Library / SDK
spencermountain/spacetime avatar
spencermountain/spacetime

spacetime's comparison example calls a 2018 date 'before' and a 2017 date 'now'

A lightweight javascript timezone library

4,106 stars194 forksJavaScriptApache-2.0

At a glance

What is it?
A dependency-free time zone library that ships its own generated zone data instead of using the platform's, where the human-readable diff example is wrong in three separate ways at once, the module entry points disagree about whether a consumer gets a build or the raw source, and the recorded home page is served over plain http while every other link is encrypted.
Who is it for?
spacetime suits a browser or Node project that wants time zone arithmetic without pulling in a large dependency and without depending on the host's own zone data being current. Check six things first.
Can I use it commercially?
Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 1 day ago.
What is it written in?
Mainly JavaScript, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 15, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • spencermountain/spacetime4,106 ★ · -1
Star history
Repository2026-09-232026-11-15
spencermountain/spacetime4.1k4.1k

-1 Stars in the last 53 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

The diff example calls the later date 'before'

The last comparison block builds a human-readable difference and gets its own example wrong three ways:

js
let s = spacetime([2017, 5, 2])
let start = s.subtract(1, 'milliseconds')
let end = s.add(1, 'milliseconds')

// gt/lt/equals
s.isAfter(d) // True
s.isEqual(d) // False
s.isBefore(d) // False
s.isBetween(start, end, inclusive?) // True

// Comparison by unit
s.isSame(d, 'year') // True
s.isSame(d, 'date') // False
s.diff(d, 'day') // 5
s.diff(d, 'month') // 0

//make a human-readable diff
let before = spacetime([2018, 3, 28])
let now = spacetime([2017, 3, 28]) //one year later
now.since(before)
// {diff: { months: 11, days: 30, ...},  rounded: 'in 12 months'  }

The variable named before holds March 2018. The variable named now holds March 2017, which is a year earlier. The comment on that line claims it is one year later, so the comment agrees with neither date. And the shown output is a positive twelve months, which is what you would get if now were the later of the two. Three statements, three different stories, and the output only makes sense if you silently swap the two dates. This is the block a reader is most prone to copying, because a readable difference object is the feature the surrounding prose is selling. The rest of the comparison examples in the file are internally consistent: a five-day difference reported as five days and zero months is right. It is the one that reaches for a year-scale example that comes apart.

The module entry points disagree about whether you get a build or the source

The manifest describes the same package two ways. The modern field, which is the one bundlers and Node both prefer, resolves an import to a built module bundle and a require to a built CommonJS bundle, with a separate type declaration file for each condition. The legacy field, which older tooling still reads, points at the raw source entry point instead. So a consumer whose tooling honours the modern field gets a bundled artefact, and one that falls back to the legacy field gets unbundled source that has to be compiled by whatever is loading it. The published file list settles the question of what is in the tarball: five directories, including the bundles, the raw source, the generated type declarations, a public API directory and the packed zone data. So the source ships as well as the build, which is generous and also means the two entry points can both work by accident rather than by design. The package is also marked as having no side effects, which is what lets a bundler drop the parts you do not call, and the manifest asks for Node 18 or newer.

The zone data is generated by the build but refreshed by a separate command

This library does not use the platform's own time zone database, and says so as a headline claim: zero dependencies, and explicitly not the browser's internationalisation API. That decision has a consequence the file does not spell out, and the tree makes it visible. The build's first step runs a script in a zone data directory that packs the data, then a script that writes the version, then the bundler. So the time zone information a consumer gets is a build artefact produced from something in the tree, not a data file that was vendored. There is a separate command for updating the zone data, and that command is not part of the build. Which means a normal release packs whatever data is currently in the tree, and the freshness of the zone rules is a manual decision rather than a consequence of publishing. The file does claim frequent updates for approaching daylight saving changes, and there is a command that does exactly that. It also claims a weight of about forty kilobytes, and the build enforces a size budget through a bundler plugin, so the figure in the prose is a limit the build checks rather than a claim nobody enforces.

Three descriptions of what the library is, and two of the three home page addresses are encrypted

The project describes itself three different ways. The repository's one-line summary calls it a lightweight time zone library. The manifest describes it as figuring out dates across time zones. The readme's own pitch calls it a date calculator, and the opening argument is about how absurd it is that there is no real date calculator. Those are three different products: a time zone library, a date utility, and a calculator you would use instead of a search engine. The home page is worse, because the address recorded for the repository uses plain http while the manifest and every link inside the readme use https. A reader arriving from a repository listing is sent to an unencrypted address first. It is a small thing and it is the kind of small thing that survives for years in a metadata field nobody opens. The manifest's own author field, by contrast, is complete and links a personal site, so the inconsistency is not general sloppiness in the file.

The headline example reassigns a variable in a library that advertises immutability

The first code block in the file is three demonstrations sharing one variable, and the third of them reassigns it:

js
let s = spacetime.now()

// Days to the end of the year:
s.diff(s.endOf('year'), 'days')
// 292

// Time it was, 11 hours ago:
s.subtract(11, 'hours').time()
// 6:50am

// Is it lunchtime in France?
s = s.goto('Europe/Paris')
s.isAfter(s.time('11:00am'))
// true 🥐

The feature list describes the interface as moment-like but immutable, and the first two demonstrations honour that, chaining off the value without touching it. The third one assigns the result back to the same name. That is not wrong, and plenty of code does it, but it is the first thing a newcomer copies and it models the opposite of the stated design. The number in the first comment is also a snapshot: two hundred and ninety-two days to the end of the year is a figure for late September, so the comment is only correct in the month it was written. Small thing, and the kind of figure that quietly stops matching.

Two of the API listings stop mid-line

The input listing ends on a call whose comment is cut off inside an unclosed bracket: a helper for the earliest possible date, with the comment trailing off after a digit and a parenthesis that is never closed. The getter and setter listing ends on a line whose comment is empty, showing a progress accessor for the hour with nothing after the marker. Both are the last line of their blocks, which suggests the blocks were pasted from a working file and trimmed rather than written for the page. The other listings in between are complete and, where they show arithmetic, correct: a five-day difference reported as five days, a set to a month and day resolving to the same year, a forward search landing on the next occurrence and a backward search on the previous one. So the file's examples are mostly trustworthy, and the two that are not are both at a block boundary, which is a cheap thing to check and an easy thing to miss.

Eight plugins are advertised and one of them lives in a differently named repository

The plugin list is two rows. Seven of the eight point into this repository's own plugin directory, covering geography, daylight handling, age, week-of-month, week-start and a start-date helper. The eighth, the calendar plugin, points at a repository whose name is abbreviated to three letters and does not match the package it installs. So a user who installs that plugin from the registry is getting code developed somewhere whose name gives no hint that it belongs to this project, and the readme offers no explanation. The root of the tree shows the same pattern of small inconsistencies. A scratch file is committed at the top level and is also the target of the watch script, so the file the developer scratches in is the file the build watches. Two of the four root documents are lower case and two are upper case. And there are three separate surfaces aimed at coding agents: a skills directory the readme installs with a one-line command, a document linked as agent docs, and an agents file at the root.

Coverage runs the test script through two layers of piping

The test setup has four scripts and they compose in ways worth reading. The main one runs a tape-based suite over a glob and pipes the raw protocol output into a pretty-printer, so the runner's output is formatted by a second program rather than by the runner. A second script runs the identical suite with an environment variable set, which is how the same tests are pointed at a production build rather than the working tree. A third pipes the standard output of a TypeScript file into that same pretty-printer, which is an unusual way to run a type check. And the coverage command invokes a coverage tool with two exclude-style patterns naming the project's own source and plugin directories, and then shells out to the test script, so the measurement happens across a chain of three processes with a pipe in the middle of it. There is also a release-check script, and the build runs a version script every time, so the version string is written into the tree by the build rather than read from it.

Editorial conclusion

spacetime suits a browser or Node project that wants time zone arithmetic without pulling in a large dependency and without depending on the host's own zone data being current. Check six things first. The zone data is a generated artefact, and the command that refreshes it is not part of the build, so a release ships whatever data was last packed. The module entry points disagree about whether a bundler sees the built bundle or the raw source. The recorded home page for the repository is an unencrypted address. The browser example loads the package by bare name from a content delivery network, so it is unpinned by construction. The comparison example that produces a human-readable diff has its two dates the wrong way round, its comment contradicting both, and output that matches neither. And eight plugins are advertised, one of which lives in a differently named repository.

Frequently asked questions

What is spacetime?

A dependency-free JavaScript library for dates across time zones, described in its own readme as a date calculator. It ships type declarations, a typed import example, a CommonJS example and a browser example, and it does not use the platform's own time zone data.

How do I install spacetime?

From the npm registry, or in a browser by including a script tag that points at the bare package name on a content delivery network, which resolves to whatever the newest published version is rather than a pinned one. The readme also gives a one-line command for adding the project to an agent's tooling.

Does spacetime use the browser's built-in time zone data?

No, and the readme says so as an explicit zero-dependency claim. The zone data is a generated artefact packed by a script during the build, and a separate command refreshes it, so the data is only as current as the last time that command was run.

How large is the spacetime library?

The readme says about forty kilobytes, and the build enforces a size budget with a bundler plugin. The published package ships five directories, including the raw source and the packed zone data alongside the bundles.

Does spacetime work with Node and TypeScript?

Yes. The manifest declares Node 18 or newer, marks the package as a module, and exports both an import and a require condition with a separate type declaration for each. The readme shows a typed import and an older CommonJS require, plus a script-tag route for browsers.

How do I produce a readable difference between two dates in spacetime?

There is a since method that returns a difference broken into months and days plus a rounded human phrase. The readme's own example for it assigns the later of two dates to a variable named before and the earlier to one named now, comments that the second is one year later, and shows a positive twelve-month result, so at least one of the three is wrong.

Official sources

  1. Issues
  2. Project website
  3. README
  4. Releases
  5. spencermountain/spacetime on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/spencermountain-spacetime.svg)](https://hysenlabs.com/projects/spencermountain-spacetime)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/spencermountain-spacetime.svg)](https://hysenlabs.com/projects/spencermountain-spacetime)

Was this useful?