Last active
February 9, 2019 08:09
-
-
Save vivekmittal/3d7d562950e28057a17927b37ef28410 to your computer and use it in GitHub Desktop.
Operational hour encoding
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const OperationalHourStepSizeInMinutes = 5 | |
func Encode(t time.Time) int64 { | |
return encode(int(t.Weekday()), t.Hour(), t.Minute()) | |
} | |
func encode(weekday int, hour int, minute int) int64 { | |
wd := ((weekday*100 + hour) * 100) + (minute/OperationalHourStepSizeInMinutes)*OperationalHourStepSizeInMinutes | |
return int64(wd) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment