Closed zemirco closed 8 years ago
Maybe add a UTC bool
field to OTPConfig
: it will default to false, but if it set to true, it uses UTC. Then the code might be:
if c.UTC {
t0 := int(time.Now().Unix() / 30)
} else {
t0 := int(time.Now().UTC().Unix() / 30)
}
I don't understand how does this make difference?
int(time.Now().UTC().Unix() / 30)
should equal to int(time.Now().Unix() / 30)
, right?
I don't understand how does this make difference?
Exactly. time.Now().Unix()
and time.Now().UTC().Unix()
will return the same value. The Unix() function returns the current Epoch value which is always UTC.
You're right.
https://golang.org/pkg/time/#Time.Unix says
The result does not depend on the location associated with t.
Seem like reverting this fix should simplify the code and otherwise be a no-op.
Oops. This is definitely the correct fix. I want to merge this, but at the same time don't want to break everybody who's currently using this code :/
Need a way to allow users to inject time, and have the local time injected by default.