time of day help

BlitzMax Forums/BlitzMax Programming/time of day help

slenkar(Posted 2009) [#1]
How would I detect if the hour was between 2 other hours?

e.g. if someone arranges to meet anytime between 11p.m, and 1 a.m.
or 2300hrs and 0100hrs

How would I detect if the current time was between those times (and all other possible times)

andd if s omeonbe worked between 11pm and 3am
how would I know if they are working (or any other possible times)


Ked(Posted 2009) [#2]
You could use these extended date and time functions that I made:

http://www.blitzbasic.com/codearcs/codearcs.php?code=2360


slenkar(Posted 2009) [#3]
sorry forgot to mention its game time not real life time.

so date and time are known factors


Ked(Posted 2009) [#4]
Does this help?
Function IsHourBetween(hour1:Int,hour2:Int)
	If hour>1 And hour<2
		Return True
	Else
		Return False
	EndIf
EndFunction



slenkar(Posted 2009) [#5]
if my character works between 11pm and 3am his last hour of work is going to be numerically less than his first hour of work.

The system has to also account for normal work hours 9am-5pm

Also if the days of work were mon-fri:

Then at 2am on saturday morning the character would stop work because

saturday is not listed as a day of work

But really the character should keep working until 3am


you could set a switch at 11pm to start work but what happens if the character is knocked out or busy until 11.30pm then the switch will never be set and he will not attempt to start work


tonyg(Posted 2009) [#6]
Use 24 hour clock and a date or day counter?
You then assign each day of the week to working or non-working used in your calculations.