Skip to content

Simple Lua library library for displaying dates as relative time ago language

License

Notifications You must be signed in to change notification settings

cosmicthemethhead/lua-timeago

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

lua-timeago

Simple Lua library library for displaying dates as relative time ago language

Installation

You can just copy the source files into your project or use the rock with luarocks.

Basic Usage

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).

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

About

Simple Lua library library for displaying dates as relative time ago language

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Lua 100.0%