Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/syarul/fuzzy-time
A simple timeago to update timestamp (e.g 4 days 12 hours 4 minutes ago) with no dependencies
https://github.com/syarul/fuzzy-time
Last synced: 3 days ago
JSON representation
A simple timeago to update timestamp (e.g 4 days 12 hours 4 minutes ago) with no dependencies
- Host: GitHub
- URL: https://github.com/syarul/fuzzy-time
- Owner: syarul
- License: mit
- Created: 2016-01-16T14:57:34.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-07-16T14:35:54.000Z (over 8 years ago)
- Last Synced: 2024-11-03T22:38:13.127Z (9 days ago)
- Language: JavaScript
- Size: 8.79 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fuzzy-time
A simple timeago to update timestamp (e.g 4 days 12 hours 4 minutes ago) with no dependencies## Usage:
to install``` npm install fuzzy-time```
As node modules
```javascript
var fuzzyTime = require('fuzzy-time')console.log(fuzzyTime('2016-01-09 23:16'))
```
Usage for browser look in **dist** folder
```html
var fuzzyTime = window.fuzzyTime;
console.log(fuzzyTime('2016-01-09 23:16'))```
#### Options Paramenters
```javascript
fuzzyTime(date, options)
```
- **setMinDays**: set the minimum days before the date is shown as actual date
- **days**: change the days string
- **hours**: change the hours string
- **minutes**: change the minutes string
- **on**: change the on string
- **setMonthArray**: Set New Array for Month ( eg: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'])
- **dateFormat**: date format, can be set to 'simple' format which output ( eg: July 20 '15)#### Sample Usage with Options
```javascript
var opts = {
setMinDays: 4,
days: 'hari',
hours: 'jam',
minutes: 'minit lepas',
on: 'pada',
setMonthArray: [
'Januari',
'Februari',
'Mac',
'April',
'Mei',
'Jun',
'Julai',
'Ogos',
'September',
'Oktober',
'November',
'Disember'
],
dateFormat: 'simple'
}
var getDate = fuzzyTime('2015-12-27 23:16', opts)console.log(getDate)
```