Twix.js allows you to work with date ranges
Twix is a comprehensive JS library for working with date ranges, and includes a customizable smart formatter. It's written in CoffeeScript and it depends on Moment.js.
var t = moment"1982-01-25T09:30"twix"1982-01-25T13:30";tformat; //=> Jan 25, 1982, 9:30 AM - 1:30 PMtisSame"day"; //=> truethumanizeLength; //=> "4 hours"tcount"days"; //=> 1tintersectionotherRange; //=> another range
See the documentation for more.
You can find comprehensive docs here:
Breaking change in 0.8.0: Twix now provides
end() accessors. Previously, it was possible to access Twix fields called
end, though they weren't documented. Because they're now functions, that will break. I did this to prevent people from mutating those dates and breaking Twix.
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:
|Install dependencies (same as |
|Run Mocha suite|
Patches are welcome!
developbranch. I merge develop to master when we cut a release.
.jsfiles in the patch; they're much harder to merge. I'll generate them when I cut the release.
Copyright 2012-2015 Isaac Cambron and contributors. Distributed under the MIT License. See LICENSE for details.