This is my first code golf so please let me know if it's too broad or if I'm missing any information for a good puzzle!
Challenge
In Ontario and possibly other areas of the world, electricity is billed using Time-Of-Use (TOU) pricing, which varies the cost per kilowatt-hour according to when you use power.
Given a date and time, I want to know whether I'm in an on-peak (red), mid-peak (yellow), or off-peak (green) time period.
Input
Assume that input is provided in an acceptable timezone-less ISO 8601 date-time format with the minimum precision of hours: YYYY-MM-DDThh[:mm[:ss]]
(the T is literal).
Examples
- 2014-09-01T14
- 2014-09-01T17:30
- 2014-09-01T17:30:02
Output
The output should be a string On
, Mid
, or Off
.
Rules
- Shortest code wins
- For the purposes of this challenge, ignore statutory holidays
- Assume the information found in this post. The actual rules of time-of-use pricing might change in the future by the Ontario Ministry of Energy.
Information
Summer weekdays (May 1st to October 31st)
- Off-peak: 19h00 - 07h00
- Mid-peak: 07h00 - 11h00 and 17h00 - 19h00
- On-peak: 11h00 - 17h00
Winter weekdays (November 1st to April 30th)
- Off-peak: 19h00 - 07h00
- Mid-peak: 11h00 - 17h00
- On-peak: 07h00 - 11h00 and 17h00 - 19h00
Weekends
- Off-peak: All day
YYYY-MM-DDThh[:mm[:ss]]
since seconds can only be applied if minutes are applied? \$\endgroup\$