# Date and time information

Followers 1

## Recommended Posts

I'm working on a cartridge that involves touring a park. One particular area of the park is closed in the Winter. Can I design the cartridge so it will automatically skip that area during the winter?

##### Link to comment

I'm working on a cartridge that involves touring a park. One particular area of the park is closed in the Winter. Can I design the cartridge so it will automatically skip that area during the winter?

You could include some author code that uses the lua function os.date (google "lua os.date" for more info) to determine the current date and insert logic based on that. This is definitely stepping outside the builder

Here is some code (incomplete) that I have been playing with in case it helps:

```dow = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" }
month = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }

function ztimerEvery5seconds:OnTick()
-- #GroupDescription=Script --
-- #Comment=Script Comment --

local i = os.date("!%c")
Wherigo.MessageBox{Text=[[]] .. i .. [[

Processed = ]] .. getdow(i) .. [[ ]] .. getdom(i) .. [[ ]]  .. getmonth(i) .. [[(]] .. getmonthnum(i) .. [[)]]  .. getyear(i)  .. [[ ]]  .. get24hour(i) .. [[:]] .. getmin(i) .. [[:]]  .. getsec(i),}
end

function getdow(t)
for j = 1 , 7, 1 do
if string.sub(dow[j], 1, 3) == string.sub(t,1,3) then
return dow[j]
end
end
end

function getmonth(t)
for j = 1 , 12, 1 do
if string.sub(month[j], 1, 3) == string.sub(t,5,7) then
return month[j]
end
end
end

function getmonthnum(t)
for j = 1 , 12, 1 do
if string.sub(month[j], 1, 3) == string.sub(t,5,7) then
return j
end
end
end

function getdom(t)
end

function getyear(t)
end

function get24hour(t)
end
function getmin(t)
end

function getsec(t)
end
```

##### Link to comment

Cool!! I think that's exactly what I was looking for. Thanks!!!!

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.