|
Overview LuaDate is a Lua module for date and time calculation and retrieval using the Gregorian Date system. It contains features such as date and time string parsing; time addition and subtraction; time span calculation and more.
Installation Here is how to make the LuaDate module available to your AutoPlay Media Studio 8.0 project. 1. Download the Lua module and extract it to a temporary location. 2. Copy the date.lua file to your project's Scripts folder. 3. Add the following require to your project, e.g. in Global Functions: require"date" -- for the date functions
Usage The function documentation can be found in either date.doc.chm or date.doc.htm contained within the date.zip download.
Example - LUA Code --Use the metamethod __call to construct a dateObject see example below:
require "date"
-- prints all FRIDAY the 13TH dates between year 2000 and 2010 and shows the result
-- in a Dialog message.
strOutput = "";
for i = 2000, 2010 do
x = date(i, 1, 1) -- year jan 1
for j = 1, 12 do -- from january to december
-- set day of month to 13, check if friday
if x:setmonth(j, 13):getweekday() == 6 then
strOutput = strOutput..x:fmt("%A, %B %d %Y").."rn";
end
end
end
-- Show result in dialog message.
Dialog.Message("Output", strOutput);
Example - Output Friday, October 13 2000 Friday, April 13 2001 Friday, July 13 2001 Friday, September 13 2002 Friday, December 13 2002 Friday, June 13 2003 Friday, February 13 2004 Friday, August 13 2004 Friday, May 13 2005 Friday, January 13 2006 Friday, October 13 2006 Friday, April 13 2007 Friday, July 13 2007 Friday, June 13 2008 Friday, February 13 2009 Friday, March 13 2009 Friday, November 13 2009 Friday, August 13 2010
Credits Copyright 2005, 2006 Jas Latrix http://alcor.concordia.ca/~gpkatch/gdate-method.html - Date calculation algorithms is based on this site.

|