Ad
  • Rename consts to generic names
  • Removed duplication in test code
Code
Diff
  • package kumite
    
    import "time"
    
    func CheckWorkHours(dateTime time.Time) bool {
      const (
        firstWorkingDay = 1
        lastWorkingDay = 5
        firstWorkingHour = 8
        lastWorkingHour = 18
      )
      
      day, hour := dateTime.Weekday(), dateTime.Hour()
      
      return firstWorkingDay <= day && day <= lastWorkingDay && firstWorkingHour <= hour && hour < lastWorkingHour
    }
    • package kumite
    • import "time"
    • func CheckWorkHours(dateTime time.Time) bool {
    • const (
    • monday, friday = 1, 5
    • morning, evening = 8, 18
    • firstWorkingDay = 1
    • lastWorkingDay = 5
    • firstWorkingHour = 8
    • lastWorkingHour = 18
    • )
    • day, hour := dateTime.Weekday(), dateTime.Hour()
    • return monday <= day && day <= friday && morning <= hour && hour < evening
    • }
    • return firstWorkingDay <= day && day <= lastWorkingDay && firstWorkingHour <= hour && hour < lastWorkingHour
    • }