v0.0.481
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 3m50s
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 3m50s
This commit is contained in:
13
timeext/diff.go
Normal file
13
timeext/diff.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package timeext
|
||||
|
||||
import "time"
|
||||
|
||||
func YearDifference(t1 time.Time, t2 time.Time, tz *time.Location) float64 {
|
||||
|
||||
yDelta := float64(t1.Year() - t2.Year())
|
||||
|
||||
processT1 := float64(t1.Sub(TimeToYearStart(t1, tz))) / float64(TimeToYearEnd(t1, tz).Sub(TimeToYearStart(t1, tz)))
|
||||
processT2 := float64(t2.Sub(TimeToYearStart(t2, tz))) / float64(TimeToYearEnd(t2, tz).Sub(TimeToYearStart(t2, tz)))
|
||||
|
||||
return yDelta + (processT1 - processT2)
|
||||
}
|
Reference in New Issue
Block a user