Icon representing a recipe

Recipe: LUA Date Time example V0.1

created by gramps

Profile


Name
LUA Date Time example V0.1
ID
44165
Shared with
Public
Parent
None
Children
None
Created on
September 16, 2012 at 16:49 PM UTC
Updated on
September 16, 2012 at 16:49 PM UTC
Description

Writes date time stamp at beginning and end plus CPU secs used

Best for


Code


-- LUA Date Time example V0.1 -- -- Writes date time stamp at beginning end plus CPU secs used -- adapted from LUA online doc 22.1 Date and Time -- http://www.lua.org/pil/22.1.html -- -- by gramps (John McLeod) -- V0.1 -- September 16, 2012 -- progname = "LUA Date Time example V0.1" -- -- MAIN stuff -- -- print program name and date/time stamp at start print(progname) -- e.g. "started 01:42:47 PM Sun Sep 16, 2012" -- see http://www.lua.org/pil/22.1.html for further options print(os.date("started %I:%M:%S %p %a %b %d, %Y")) print(os.date("%z")) -- time zone print("") -- print("this program demonstrates some Date/Time stuff from online LUA docs") print("") -- -- The following is copied directly from the Doc 22.1 page: -- -- The os.clock function returns the number of seconds of CPU time -- for the program. Its typical use is to benchmark a piece of code: -- local x = os.clock() local s = 0 for i=1,1000 do s = s + i end -- to 100000 in original print(string.format("elapsed time: %.2f cpu secs\n", os.clock() - x)) -- -- print program name and date/time stamp at end print(progname) print(os.date("ended %I:%M:%S %p %a %b %d, %Y")) print(os.date("%z")) -- time zone -- -- end LUA Date Time example V0.1

Comments


gramps Lv 1

LUA Date Time example V0.1
started 01:49:45 PM Sun Sep 16, 2012
Atlantic Daylight Time

this program demonstrates some Date/Time stuff from online LUA docs

elapsed time: 0.03 cpu secs

LUA Date Time example V0.1
ended 01:49:45 PM Sun Sep 16, 2012

gramps Lv 1

– LUA Date Time example V0.1

– Writes date time stamp at beginning end plus CPU secs used
– adapted from LUA online doc 22.1 Date and Time
http://www.lua.org/pil/22.1.html

– by gramps (John McLeod)
– V0.1 – September 16, 2012

progname = "LUA Date Time example V0.1"

– MAIN stuff

– print program name and date/time stamp at start
print(progname)
– e.g. "started 01:42:47 PM Sun Sep 16, 2012"
– see http://www.lua.org/pil/22.1.html for further options
print(os.date("started %I:%M:%S %p %a %b %d, %Y"))
print(os.date("%z")) – time zone
print("")

print("this program demonstrates some Date/Time stuff from online LUA docs")
print("")

– The following is copied directly from the Doc 22.1 page:

– The os.clock function returns the number of seconds of CPU time
– for the program. Its typical use is to benchmark a piece of code:

local x = os.clock()
local s = 0
for i=1,1000 do s = s + i end – to 100000 in original
print(string.format("elapsed time: %.2f cpu secs\n", os.clock() - x))

– print program name and date/time stamp at end
print(progname)
print(os.date("ended %I:%M:%S %p %a %b %d, %Y"))
print(os.date("%z")) – time zone

– end LUA Date Time example V0.1