-
Notifications
You must be signed in to change notification settings - Fork 886
fix: strip timezone information from a date in dau response #11962
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Timezone information is lost, so do not forward it to the client.
func TimezoneOffsetHour(loc *time.Location) int { | ||
// TimezoneOffsetHourWithTime is implemented to match the javascript 'getTimezoneOffset()' function. | ||
// This is the amount of time between this date evaluated in UTC and evaluated in the 'loc' | ||
// The trivial case of times being on the same day is: | ||
// 'time.Now().UTC().Hour() - time.Now().In(loc).Hour()' | ||
func TimezoneOffsetHourWithTime(now time.Time, loc *time.Location) int { | ||
if loc == nil { | ||
// Default to UTC time to be consistent across all callers. | ||
loc = time.UTC | ||
} | ||
_, offsetSec := time.Now().In(loc).Zone() | ||
// Convert to hours | ||
return offsetSec / 60 / 60 | ||
_, offsetSec := now.In(loc).Zone() | ||
// Convert to hours and flip the sign | ||
return -1 * offsetSec / 60 / 60 | ||
} | ||
|
||
func TimezoneOffsetHour(loc *time.Location) int { | ||
return TimezoneOffsetHourWithTime(time.Now(), loc) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This value was flipped from the javascript implementation. Given this value comes from the browser, I made it match the javascript. I fixed all the tests to be deterministic so we can keep them on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also verified this is the same on Postgres
Timezone information is lost, so do not forward it to the client.
See issue for debugging details
Closes #11943