Socket
Book a DemoInstallSign in
Socket

moment.twitter

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

moment.twitter

Twitter-lioke Date Formatter

latest
Source
npmnpm
Version
0.0.1
Version published
Maintainers
1
Created
Source

Twitter-like Date Formatter

moment.twitter.js is an extension to moment.js that formats dates like Twitter.

Works on both past and future dates.

Methods

moment().twitter()

Web-friendly formatting (alias moment().twitterLong()).

Examples:

Formats time relative to current time.

moment(moment() + (36e5 * 5)).twitter()
// 5 hours

Yes, it does smart pluralization.

moment(moment() + 36e5).twitter()
// 1 hour

Times greater than 24 hours are converted to dates like Mar 7

moment(moment() + 6048e5).twitter()
// Mar 7

moment().twitterShort()

For use on mobile.

Examples:

Units single characters, and there are no spaces.

moment(moment() + (36e5 * 5)).twitterShort()
// 5h

Times greater than 24 hours but more than 6 days are converted to days.

moment(moment() + (864e5 * 6)).twitterShort()
// 6d

Times greater than 6 days are slash-separated.

moment(moment() + 6048e5).twitterShort()
// 3/7/86

TODO

  • Write some bad ass tests.
  • Compile this with grunt, I guess.
  • Get @timrwood to close timrwood/momentjs.com#24
  • npm, require, commonjs, etc support.

Keywords

Twitter

FAQs

Package last updated on 22 Apr 2013

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