Use UTC() everywhere

ref - https://github.com/golang/go/issues/1988, no standard function to set timeZone
This commit is contained in:
Harshavardhana
2015-04-30 19:26:23 -07:00
parent b6d96335e7
commit 8e3d48bf35
6 changed files with 38 additions and 36 deletions

View File

@@ -35,7 +35,7 @@ type quotaMap struct {
func (q *quotaMap) CanExpire() {
q.Lock()
defer q.Unlock()
currentMinute := time.Now().UnixNano() / q.segmentSize.Nanoseconds()
currentMinute := time.Now().UTC().UnixNano() / q.segmentSize.Nanoseconds()
// divide by segmentSize, otherwise expiredQuotas will always be negative
expiredQuotas := currentMinute - (q.duration.Nanoseconds() / q.segmentSize.Nanoseconds())
for time := range q.data {
@@ -49,7 +49,7 @@ func (q *quotaMap) Add(ip uint32, size int64) {
q.CanExpire()
q.Lock()
defer q.Unlock()
currentMinute := time.Now().UnixNano() / q.segmentSize.Nanoseconds()
currentMinute := time.Now().UTC().UnixNano() / q.segmentSize.Nanoseconds()
if _, ok := q.data[currentMinute]; !ok {
q.data[currentMinute] = make(map[uint32]int64)
}