Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/f-person/lua-timeago
Simple Lua library library for displaying dates as relative time ago language
https://github.com/f-person/lua-timeago
lua lua-library luajit timeago
Last synced: 27 days ago
JSON representation
Simple Lua library library for displaying dates as relative time ago language
- Host: GitHub
- URL: https://github.com/f-person/lua-timeago
- Owner: f-person
- License: lgpl-2.1
- Created: 2021-04-11T15:12:41.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2024-07-27T14:25:49.000Z (6 months ago)
- Last Synced: 2024-12-18T08:03:50.297Z (29 days ago)
- Topics: lua, lua-library, luajit, timeago
- Language: Lua
- Homepage:
- Size: 19.5 KB
- Stars: 8
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# lua-timeago
Simple Lua library for displaying dates as relative time ago language## Installation
You can just copy the source files into your project or use the [rock](https://luarocks.org/modules/f-person/lua-timeago) with [luarocks](https://luarocks.org/).## Basic Usage
```lua
local timeago = require('lua-timeago')local now = os.time()
timeago.format(now - (60 * 5)) -- Returns '5 minutes ago'
```### Language
The library uses English by default. You can set the language with `set_language`
function. It accepts a string with the language file name from the `languages`
directory or a dictionary with language rules (take a look at `languages/en.lua` for an example).```lua
local timeago = require('lua-timeago')local now = os.time()
timeago.format(now - (60 * 5)) -- Returns '5 minutes ago'timeago.set_language('hy')
timeago.format(now - (60 * 5)) -- Returns '5 րոպե առաջ'
```---
Thanks to [wscherphof/lua-timeago](https://github.com/wscherphof/lua-timeago)