-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
Description
by pkorotkov:
What steps will reproduce the problem?
This code does not work in Go Playground as-is, so just put it right there:
// DatesDiff returns the number of days and seconds resp. between two given dates
func DatesDiff(t1, t2 time.Time) (int, int64) {
v := int64(t2.Sub(t1))
return int(v / 864e11), v / 1e9
}
func main() {
loc, err := time.LoadLocation("Europe/Berlin")
if err != nil {
fmt.Println(err.Error())
return
}
t1 := time.Date(1957, time.September, 10, 0, 0, 0, 0, loc)
t2 := time.Date(2013, time.May, 14, 0, 0, 0, 0, loc)
fmt.Println(DatesDiff(t1, t2))
t3 := time.Date(1957, time.September, 10, 0, 0, 0, 0, time.UTC)
t4 := time.Date(2013, time.May, 14, 0, 0, 0, 0, time.UTC)
fmt.Println(DatesDiff(t3, t4))
}
What is the expected output?
20335 1756944000
20335 1756944000
What do you see instead?
20334 1756940400
20335 1756944000
Which compiler are you using (5g, 6g, 8g, gccgo)?
8g
Which operating system are you using?
Windows 7 Prof x86
Ubuntu Linux 12.04 LTS x86
Which version are you using? (run 'go version')
go version go1.0.1
Please provide any additional information below.