Calendar one month to go! help
kjfluke
Member, PRO Posts: 23
Hi. I have a really lame problem. I have been looking through the forums for an answer that I can use and can't quite get there, so I apologize if this is a frequently asked question. I have an app that displays different text for each day of the year, called from a table. What I am trying to do is have it recognize when todays date is one month before a certain date. Or one week before. The year is irrelevant. I tried using a subtraction method like this:
(game.Clock.Month+11)%12
which works well but I can't remember how to make it skip 0. Any quick help would be greatly appreciated.
-K
(game.Clock.Month+11)%12
which works well but I can't remember how to make it skip 0. Any quick help would be greatly appreciated.
-K
Best Answer
-
RThurman Posts: 2,881What you are doing is correct. (I was just answering how you skip "0" in a sequence. I was not answering how to determine what the next month is.)
Answers
(game.Clock.Month+11)%12+1
sounds like it should work. Thanks T-shirt Booth.
((a-1)%b)+1
For months of the year it would look something like:
(game.Clock.Month-1)%12+1
Here month 12 would be "12" and month 13 would be "1"
(game.EventMonth-2)%12+1. That seems to have worked, though I don't know why the other didn't work.