MySQL interval with date/time expression arithmetic.

This commit is contained in:
go-jet 2019-12-01 18:25:30 +01:00
parent 15acb1c326
commit d1970b3a55
41 changed files with 805 additions and 318 deletions

View file

@ -9,6 +9,7 @@ import (
"path/filepath"
"reflect"
"strings"
"time"
)
// ToGoIdentifier converts database to Go identifier.
@ -182,3 +183,21 @@ func StringSliceContains(strings []string, contains string) bool {
return false
}
func ExtractDateTimeComponents(duration time.Duration) (days, hours, minutes, seconds, microseconds int64) {
days = int64(duration / (24 * time.Hour))
reminder := duration % (24 * time.Hour)
hours = int64(reminder / time.Hour)
reminder = reminder % time.Hour
minutes = int64(reminder / time.Minute)
reminder = reminder % time.Minute
seconds = int64(reminder / time.Second)
reminder = reminder % time.Second
microseconds = int64(reminder / time.Microsecond)
return
}