v0.0.481
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 3m50s

This commit is contained in:
2024-07-04 16:24:49 +02:00
parent 19d943361b
commit abc8af525a
5 changed files with 137 additions and 2 deletions

13
timeext/diff.go Normal file
View 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)
}