goext/timeext/diff.go
Mike Schwörer abc8af525a
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 3m50s
v0.0.481
2024-07-04 16:24:49 +02:00

14 lines
431 B
Go

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)
}