twix

Twix.js allows you to work with date ranges

Twix.js

Twix is a simple but opinionated JS library for working with date ranges, and includes a customizable smart formatter. It's written in CoffeeScript and it depends on Moment.js.

It allows you to do, among other things, this:

var t = moment("1982-01-25T09:30").twix("1982-01-25T13:30");
 
t.format();  //=> Jan 25, 1982, 9:30 AM - 1:30 PM 
 
t.isSame("day"); //=> true 
t.humanizeLength(); //=> "4 hours" 
t.count("days"); //=> 1 

And much more.

InfoBadges
Version
License
Popularity
Testing
Quality
Phasers

You can find comprehensive docs here:

Detailed documentation

Breaking change in 0.7.0: Twix formatting internationalization (just French, really) is no longer supported. It doesn't seem to have had a lot of use, and it's pain to maintain. Don't worry, we still support Moment's internationalized tokens.

If you want to build and test Twix for yourself, make wraps everything you need:

CommandFunction
make configureInstall dependencies (same as npm install)
make buildCompile JS
make testRun Mocha suite
make lintLinter
make benchMicrobenchmarks

Patches are welcome!

  • Submit pull requests to the develop branch. I merge develop to master when we cut a release.
  • Don't include your changes to the generated .js files in the patch; they're much harder to merge. I'll generate them when I cut the release.
  • Make sure you run the linter and the tests before submitting a PR.

CHANGELOG

Copyright 2012-2015 Isaac Cambron and contributors. Distributed under the MIT License. See LICENSE for details.