Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wscherphof/lua-timeago
Turn a timestamp into a friendly string of how long ago it was
https://github.com/wscherphof/lua-timeago
Last synced: about 1 month ago
JSON representation
Turn a timestamp into a friendly string of how long ago it was
- Host: GitHub
- URL: https://github.com/wscherphof/lua-timeago
- Owner: wscherphof
- License: other
- Created: 2013-06-20T12:02:33.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-06-21T08:53:08.000Z (over 11 years ago)
- Last Synced: 2024-10-09T13:57:43.972Z (about 1 month ago)
- Language: Lua
- Size: 121 KB
- Stars: 6
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# lua-timeago
Turn a timestamp into a friendly string of how long ago it was
## Usage
### 1. Install
Setup [lua-loader](https://github.com/wscherphof/lua-loader) and then just `npm install lua-timeago`### 2. Require
```lua
local timeago = require("lua-timeago")
```### 3. Have fun
```lua
assert(timeago.parse() == "just now")
assert(timeago.parse("2011-06-21") == "2 years")
timeago.setlanguage("nederlands")
assert(timeago.parse() == "zojuist")
assert(timeago.parse("2011-06-21") == "2 jaar")
```
You can feed it anything that is swallowed by [lua-date](https://github.com/wscherphof/lua-date): date/time strings in different formats, or a lua-date date object.
The default language is `"english"`, and some other languages are readily available. You can provide a new language by passing a table with all the values (see [english.lua](english.lua)), but if you do that, don't forget to issue a pull request as well.## License
[GNU Lesser General Public License (LGPL)](http://www.gnu.org/licenses/lgpl-3.0.txt)