1.1.2 • Published 4 years ago

losstime v1.1.2

Weekly downloads
1
License
ISC
Repository
github
Last release
4 years ago

losstime

Calculate how long a time stamp has passed.

Instalation

npm i losstime

Syntax

losstime(timestamp, config)
ParameterDescription
timestamp· A timestamp and type is Number.· Not required.· Default value: Date.now()
config· A configure and type is Object.· Not required.· Default value:{ day: '天', hour: '小时', minutes: '分钟', before: '之前', justNow: '刚刚' }

Example

import { losstime } from 'losstime';

losstime() // "刚刚";

var oneMinutes = 60 * 1000;
var oneHour = 1 * 60 * oneMinutes;
var oneDay = 24 * oneHour;

losstime(Date.now() - oneDay) // "1天之前"
losstime(Date.now() - (oneDay + oneHour)) // "1天1小时之前"
losstime(Date.now() - (oneDay + oneHour + oneMinutes)) // "1天1小时1分钟之前"

Tips

Currently only Chinese is supported.

But you can internationalize it by passing in config parameters.

1.1.2

4 years ago

1.1.1

4 years ago

1.0.2

4 years ago

1.1.0

4 years ago

1.0.1

6 years ago

1.0.0

6 years ago