0.2.7 • Published 5 years ago

tools.js v0.2.7

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

tools.js

Coverage Status

Use

Install

yarn add tools.js or npm i -S tools.js

ES2015+:

import { xxx } from 'tools.js'

目录

API

Date

format(date, template)

返回指定格式的时间字符串。

  Arguments:
    date: timestamp or FormatDateTime; defalut: new Date()
    template: y: year, M: month, d: day, h: hour, m: minute, s: second; defalut: 'y-M-d h:m'
    
  Returns: String

  Example:
    format(1528128000000)
    // 2018-06-05 00:00

    format(1528128000000, 'YYY/MM/DD h:m:s')
    // 2018/06/05 0:0:0

fromNow(date, date2)

计算并返回可读时间差。

  Arguments:
    date: timestamp or FormatDateTime
    date2: timestamp or FormatDateTime

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

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

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

Number

isNumber(num)

判断num是否为Number

  Arguments: num: any

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

5 years ago

0.2.6

5 years ago

0.2.5

5 years ago

0.2.4

5 years ago

0.2.3

5 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago

0.0.4

9 years ago