thenceforth
Date/Time parsing to human readable messages
Last updated 2 years ago by stevelacy .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install thenceforth 
SYNC missed versions from official npm registry.

Thenceforth

Parse Date() to human readable time messages

Other time libraries dealing with "time since" or "time ago" do not have a limit on when to switch from a date sentence to a formatted date. This tiny (1.4k uncompressed ) library returns the human readable date sentence up to one month ago, where it returns either the base form mm/dd/yyyy or the pretty form 'Day Month day, Year'

Install

$ npm i thenceforth
$ yarn add thenceforth

Example

Times are parsed to when they happened in a day:

thenceforth(new Date())
// => Just now

const twentyMinutes = 60000 * 20
thenceforth(new Date().getTime() - twentyMinutes)
// => 20 minutes ago

While times greater than one month are returned as a date:


thenceforth(new Date('2010-10-11T00:00:00+05:30')))
// => 'Monday November 1, 2010'

The full form date is much easier to understand than "one year ago", as one year could be any month within 10-14 months ago. Also the day is not provided with "one year ago", and "five years ago" does not make sense for date specific events.

Current Tags

  • 0.2.1                                ...           latest (2 years ago)

5 Versions

  • 0.2.1                                ...           2 years ago
  • 0.2.0                                ...           2 years ago
  • 0.1.2                                ...           2 years ago
  • 0.1.1                                ...           2 years ago
  • 0.1.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (1)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |