0.0.2 • Published 6 years ago

dates.js v0.0.2

Weekly downloads
5
License
MIT
Repository
github
Last release
6 years ago

dates.js

Coverage Status Build Status

Installation

In a browser:

<script src="dates.js"></script>

use: _.xxx()

Using npm:

npm i -S dates.js

In Node.js:

const _ = require('dates.js')

API

fromNow(date, options)

calculating readable time differences from now and past or future dates.

  Arguments:
    date: timestamp or FormatDateTime
    options: timestamp or FormatDateTime

  Returns:
    (String): "1秒以前 or 1分钟以前 or 1小时以前 or 1天以前 ..."

  Example:
    fromNow('2018/01/01');
    // 2018/01/01 => new Date()

    forNow('2018/01/01', '2018/01/02')
    // 2018/01/01 => 2018/01/02

isNumber(num)

Returns true if the value is a number or string number.

  Arguments: num: any

  Returns: Boolean
  
  Example:
    isNumber('') //false
    isNumber(Infinity) //false
    isNumber('123') // true