https://github.com/yocontra/thenceforth
🕥Date/Time parsing to human readable messages
https://github.com/yocontra/thenceforth
date time timeago timeparser
Last synced: 10 months ago
JSON representation
🕥Date/Time parsing to human readable messages
- Host: GitHub
- URL: https://github.com/yocontra/thenceforth
- Owner: yocontra
- License: mit
- Created: 2018-11-28T05:26:34.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-09-27T16:13:29.000Z (over 3 years ago)
- Last Synced: 2025-03-30T01:04:43.201Z (11 months ago)
- Topics: date, time, timeago, timeparser
- Language: JavaScript
- Homepage:
- Size: 12.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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
```sh
$ npm i thenceforth
```
```sh
$ yarn add thenceforth
```
### Example
Times are parsed to when they happened in a day:
```js
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:
```js
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.