Skip to content

Commit

Permalink
revert time/date functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jackwakefield committed Sep 15, 2014
1 parent 9b60e19 commit 82d659e
Showing 1 changed file with 0 additions and 42 deletions.
42 changes: 0 additions & 42 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,12 @@ import (
"os"
"regexp"
"strings"
"time"

"github.com/robertkrimen/otto"
)

const dnsServer = "8.8.8.8:53"

var weekDays = map[string]time.Weekday{
"SUN": time.Sunday,
"MON": time.Monday,
"TUE": time.Tuesday,
"WED": time.Wednesday,
"THU": time.Thursday,
"FRI": time.Friday,
"SAT": time.Saturday,
}

// isPlainHostName return true if there is no domain name in the host.
func isPlainHostName(host string) bool {
return strings.Index(host, ".") == -1
Expand Down Expand Up @@ -121,34 +110,3 @@ func shExpMatch(str, shexp string) bool {

return err == nil && matched
}

// weekdayRange returns true if the current weekday is between wd1 and wd2.
// If wd2 is unspecified, weekdayRange returns true if the weekday matches wd1.
func weekdayRange(wd1, wd2, gmt string) bool {
if _, ok := weekDays[wd1]; !ok {
return false
}

if wd2 == "GMT" {
gmt = wd2
wd2 = ""
}

now := time.Now()

if gmt == "GMT" {
now = now.UTC()
}

if wd2 == "" {
return now.Weekday() == weekDays[wd1]
}

if weekDays[wd1] > weekDays[wd2] {
weekDay1 := weekDays[wd1]
weekDays[wd2] = weekDays[wd1]
weekDays[wd1] = weekDay1
}

return weekDays[wd1] <= now.Weekday() && weekDays[wd2] >= now.Weekday()
}

0 comments on commit 82d659e

Please sign in to comment.