Hi,
I want to write some sort of dictionary that would accept current time and return what user-define time period it is. As time-preiod I mean user-defined names for time period that are read from file. For example
8:00-9:00 - breakfast time 9:00-12:00 - work time 12:00-13:00 - lunch time
etc...
Currently I have a function is base on if-else if statements
// C# syntax omitted for simplicity
TimePeriod GetCurrentTimePeriod(DateTime t)
{
if(t < 8.00)
{
return TimePeriod.Sleep;
}
else if(t < 9.00)
{
...
}
}
I am not happy with this straight solution. I would prefer use some sort of "dictionary" instead.
PS. Changed the word TimeZone to TimePeriod to avoid confusion with System.TimeZone class.