Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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)
```