refactor OffPeakTimePreriods with timezone support
- Move the .In(location) call to inside of InPeriod(). Then the GetCurrentTime() function will be responsible only for returning a current time for purpose of altering this time in tests. - Update the timeSince calculation to use the time returned by GetCurrentTime() instead of internal time.Now(). - Update the comparison to check if the timeSince is inside of the closed interval [time-1s, time+1s] instead of the open interval (time-1s, time+1s). - additional Tests for: - user uses the Europe/Berlin timezone business hours, - user uses UTC as Runner's host timezone, - user defines OffPeakPeriod representing the 10-18 hours each day. TimePeriod is initialized with above data (so period having the 10-18 hours definition and Europe/Berlin timezone). The test should confirm that the InPeriod() call should return: - TRUE for the 2017-01-01 16:30:00 UTC (no DST time in Europe/Berlin, so the time is +1h to the UTC time - 17:30 - which is inside of the time period), - FALSE for the 2017-07-01 16:30:00 UTC (DST time in Europe/Berlin, so the time is +2h to the UTC time - 18:30 - which is outside of the time period).
Showing with 52 additions and 45 deletions