Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bahamas10/human
show seconds in a human-readable form
https://github.com/bahamas10/human
Last synced: about 2 months ago
JSON representation
show seconds in a human-readable form
- Host: GitHub
- URL: https://github.com/bahamas10/human
- Owner: bahamas10
- Created: 2014-08-19T17:18:23.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2018-12-27T06:50:13.000Z (almost 6 years ago)
- Last Synced: 2024-05-08T20:01:41.326Z (8 months ago)
- Language: C
- Size: 5.86 KB
- Stars: 11
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
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
``` js
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 minutesWith 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 agoLicense
-------MIT