我已经验证了dateutils.tz.tzlocal()在heroku上不起作用,即使它确实如此,它不会只是从计算机的操作系统中获取tz,而不是用户吗?
如果没有存储用户时区,有没有办法确定请求的来源? (我正在使用烧瓶)
解决方法
您可以使用
Javascript并在cookie中设置客户端的时区.您甚至可以使用AJAX请求,然后将偏移量发送到服务器并保存在客户端的会话中.
var offset = new Date().getTimezoneOffset();
Description
The time-zone offset is the difference,in minutes,between UTC and local time. Note that>this means that the offset is positive if the local timezone is behind UTC and negative if it is ahead. For example,if your time zone is UTC+10 (Australian Eastern Standard Time),-600 will be returned. Daylight savings time prevents this value from being a constant even for a given locale