Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

twix

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

twix

Twix.js allows you to work with date ranges

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Twix.js

MIT License Build Status Code Coverage Code Climate Dependencies Version NPM version Bower version

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.

Some examples:

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
t.intersection(otherRange); //=> another range

See the documentation for more.

Documentation

You can find comprehensive docs here:

Detailed documentation

Breaking change in 0.9.0: The showDate smart format option has been deprecated but also modified. It previously hid the date if the range spanned only one day, regardless of the day. I found that confusing, so you now have two options: a. hide the date with hideDate: true or b. use implicitDate: true to elide the date if it spans one day and that day is today. showDate has been aliased to !implicitDate, though that behavior is not consistent with the old behavior. If for some reason "hide the date if the range spans only one day" is a real use case for you that I just broke, please let me know.

Building

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

CommandFunction
make configureInstall dependencies (same as npm install)
make or make buildCompile src/*.coffee to dist/*.js
make testRun Mocha suite
make lintLinter
make benchMicrobenchmarks

Contributing

Patches are welcome!

  • 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. Use make lint and make test.
  • If you make a change that will need documentation, make the appropriate update to docs. It will get published to the website on the next release.

Changelog

CHANGELOG

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

Phasers to stun

Keywords

FAQs

Package last updated on 26 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc