dromara / carbon

A simple, semantic and developer-friendly golang package for time.
https://pkg.go.dev/github.com/dromara/carbon/v2
MIT License
4.83k stars 242 forks source link

method: a.DiffInDuration(b) is b-a ! This is not in line with intuition #239

Closed zhangdekui closed 4 months ago

zhangdekui commented 4 months ago

This is very easy to make mistakes... The following code is the standard library of golang: b := time.Date(2022, time.March, 10, 10, 0, 0, 0, time.UTC) a := time.Now() diff := a.Sub(b) fmt.Println(diff.Hours())

result is 20464.558380785, is a-b !

gouguoyin commented 4 months ago

The API has been determined and cannot be changed arbitrarily