Musique/node_modules/human-time
2021-12-06 16:34:00 +01:00
..
tests Update to v13 and add queue and completely change code 2021-12-06 16:34:00 +01:00
human.bash Update to v13 and add queue and completely change code 2021-12-06 16:34:00 +01:00
human.c Update to v13 and add queue and completely change code 2021-12-06 16:34:00 +01:00
human.js Update to v13 and add queue and completely change code 2021-12-06 16:34:00 +01:00
Makefile Update to v13 and add queue and completely change code 2021-12-06 16:34:00 +01:00
package.json Update to v13 and add queue and completely change code 2021-12-06 16:34:00 +01:00
README.md Update to v13 and add queue and completely change code 2021-12-06 16:34:00 +01:00

human

show seconds in a human-readable form

Usage

This repository comes with a couple of implementations of the base algorithm in different languages. You can use any by simply dropping the logic into your source code.

Node.JS

You can install the javascript version of this with

npm install human-time

and use it like

var human = require('human-time');

human(754);
// => "12 minutes ago"

human(new Date(Date.now() + 5 * 1000))
// => "5 seconds from now"

human(new Date(Date.now() - 5 * 1000))
// => "5 seconds ago"

Example (C)

compile

make

run

$ ./human 65
1 minute
$ ./human 600
10 minutes

With the C example, you can optionally pass -s to get a suffix

$ ./human 57483
15 hours
$ ./human -s 57483
15 hours from now
$ ./human -s -57483
15 hours ago

License

MIT