PDA

View Full Version : Lua Date & Time Library



Dermot
03-11-2010, 07:23 PM
Very nice OOP style Lua date & time library here http://luaforge.net/frs/?group_id=209&release_id=508

Just drop the date.lua file in the Scripts folder and add require("date") to your globals. There is a very good help file included.

Example of the diff method

-- get the days between two dates
local diff = date.diff("Jan 7 2010", "Jan 12 2010")
Dialog.Message("Diff", diff:spandays())

There is also spanhours, spanminutes and spanseconds methods

You can also do cool stuff like this

local a = date("Jan 7 2010")
local b = date("Jan 12 2010")

local days = (b-a):spandays()

T3STY
03-11-2010, 07:47 PM
Nice!
I was looking for something like this some time ago for a project, now suspended. I think I'll continue the project one day.. I hope to..

Thanks Dermot!

RizlaUK
03-12-2010, 03:29 AM
nice find Dermot :yes

this can really help

i give it 30 minuets before Bas works this into his LOOP plugin

Imagine Programming
03-12-2010, 03:53 PM
nice find Dermot :yes

this can really help

i give it 30 minuets before Bas works this into his LOOP plugin

.... :cool

Nice find Dermot! :yes

Dermot
03-12-2010, 04:16 PM
The license agreement strictly prohibits the making of an AMS plugin from this library. :)

Seriously though, this does not need to be made into a plugin. It is one small lua file and it is very very easy to use.

Imagine Programming
03-12-2010, 05:34 PM
The license agreement strictly prohibits the making of an AMS plugin from this library. :)

Seriously though, this does not need to be made into a plugin. It is one small lua file and it is very very easy to use.

No indeed, you could copy-paste the code to globals lol. I must say,
I laughed when I read the in-script comment 'keep out of reach of children.' haha :yes