Created
May 8, 2018 07:13
-
-
Save matejb/fa7195b5bf37014fe2a98f14d3aef7b6 to your computer and use it in GitHub Desktop.
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
// normalizeLocalTime will normalize local time expressed in number of seconds | |
// from UNIX Epoch but not in UTC but counted in local location to the one | |
// counted correctly from UTC location. | |
func normalizeLocalTime(localNumOfSeconds int64, location *time.Location) time.Time { | |
t := time.Unix(localNumOfSeconds, 0).In(location) | |
_, offset := t.Zone() | |
// we apply offset in reverse to correct time | |
return t.Add(-1 * time.Duration(offset) * time.Second) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment