Back to Recipes Homepage
recipe picture
Recipe: LUA Date Time example V0.1
Created by gramps 78 1437
0
Your rating: None

Profile

Name: LUA Date Time example V0.1
ID: 44165
Created on: Sun, 09/16/2012 - 16:49
Updated on: Sun, 09/16/2012 - 16:49
Description:

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



Best For


Comments

gramps's picture
User offline. Last seen 5 years 12 weeks ago. Offline
Joined: 12/16/2010
recipe output

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's picture
User offline. Last seen 5 years 12 weeks ago. Offline
Joined: 12/16/2010
source 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

Want to try?
Add to Cookbook!
To download recipes to your cookbook, you need to have the game client running.
Parent

none

Children

none

Authors
Sitemap

Developed by: UW Center for Game Science, UW Institute for Protein Design, Northeastern University, Vanderbilt University Meiler Lab, UC Davis
Supported by: DARPA, NSF, NIH, HHMI, Amazon, Microsoft, Adobe, RosettaCommons