chronosis
v0.2.0
Published
An extremely lightweight, modern date management library
Downloads
3
Maintainers
Readme
[!WARNING]
Chronosis is currently in BETA. Expect frequent breaking changes as the API and codebase matures.
The fastest and smallest date manipulation library.
- Tiny: Gzips to less than 1 kilobyte, comparable to the size of only date-fns's
add
function. That's ~3x smaller than dayjs and ~22x smaller than luxon! - Simple: Only includes necessary functions for manipulation and formatting, excluding excess like equality comparisons.
- Absurdly fast: Significantly faster at nearly every single common action than any other similar package.
- I18N: Implements
Intl.DateTimeFormat
to translate language-specific terms via the browser.
Installation
To install, use your preferred package manager to download chronosis
.
npm install chronosis
chronosis
is developed on Linux, using bun.sh as package manager, script runner, bundler, and test runner. Certain parts of the project may work on Windows, but it is highly suggested to install WSL and continue from there.
Once complete, just import the Chronosis
class into your code, and start programming!
Usage
Manipulating dates and times should be simple, so Chronosis
makes it easy.
import { Chronosis } from 'chronosis'
const now = new Chronosis()
// Familiar, chainable syntax
const noon_tomorrow = now.add(1, 'day').set('hour', 11).startOf('hour')
// Intuitive, internationalized formatting
console.log(noon_tomorrow.format('dddd, MMMM D, YYYY', 'es-MX'))
// Logs something like 'sábado, septiembre 9, 2023'
For more detailed information and documentation, see chronosis.js.org.
Examples
Find how many days are left in the month
const now = new Chronosis()
const end_of_month = now.endOf('month')
const days_left = end_of_month.get('day') - now.get('day')
Contributing
Please see CONTRIBUTING.md to see how best to contribute to this project.