timezone

How to transform IP addresses into geolocation in BigQuery standard SQL?

一笑奈何 提交于 2020-01-04 00:44:17
问题 So I have read https://cloudplatform.googleblog.com/2014/03/geoip-geolocation-with-google-bigquery.html But I was wondering if there was a #standardSQL way of doing it. So far, I have a lot of challenge converting PARSE_IP and NTH() since the suggested changes in the migration docs have limitations. Going from PARSE_IP(contributor_ip) to NET.IPV4_TO_INT64(NET.SAFE_IP_FROM_STRING(contributor_ip)) does not work for IPv6 IP addresses. Going from NTH(1, latitude) lat to latitude[SAFE_ORDINAL(1)]

Showing MySQL timestamps in local time

不羁的心 提交于 2020-01-03 21:09:43
问题 I have a MySQL database with a lot of data stored with timestamps all in UTC time. When a user queries that database, I want them to be able to view the data but in their local timezone. I'd prefer not to have to calculate an offset each time and change the timestamp with PHP code. Is there any other way? 回答1: You can use localtime() function to get the local time and find the matching records from database. 回答2: It is possible to set a timezone per connection with mysql like so: SET time

Showing MySQL timestamps in local time

白昼怎懂夜的黑 提交于 2020-01-03 21:09:04
问题 I have a MySQL database with a lot of data stored with timestamps all in UTC time. When a user queries that database, I want them to be able to view the data but in their local timezone. I'd prefer not to have to calculate an offset each time and change the timestamp with PHP code. Is there any other way? 回答1: You can use localtime() function to get the local time and find the matching records from database. 回答2: It is possible to set a timezone per connection with mysql like so: SET time

Does datetime.fromtimestamp(os.path.getctime()) in Python give me a timezone-aware value?

陌路散爱 提交于 2020-01-03 19:03:25
问题 I am using calls such as this in Python 3.4: x = datetime.fromtimestamp(os.path.getctime(somefilename)) y = datetime.fromtimestamp(os.path.getmtime(somefilename)) Will x and y be timezone-aware, as per the definition of that term in the datetime documentation? Does this vary between platforms? I assume that in theory the ctime and mtime of a file are measured against the seconds since the epoch in UTC, so the answer should be yes? If so, is that true across all/most POSIX platforms?

Set user time zone dynamically with devise

时光毁灭记忆、已成空白 提交于 2020-01-03 18:04:34
问题 I've built a rails app that helps parents keep track of their infants’ sleep. For it to work properly I've had to support different time zones. To avoid annoying the user with time zones, I've created a little javascript that adds a hidden field to the login form, including the timezone offset. Here's the code var timeZoneField = $("input[name='user_tz_offset']"); if (timeZoneField.length) { var browserDate = new Date(); var timeZoneOffsetSeconds = (browserDate.getTimezoneOffset() * 60) * -1;

NoMethodError: Undefined method 'type' for nil:NilClass in Rails

南楼画角 提交于 2020-01-03 17:27:30
问题 Getting a NoMethodError when trying to load up one of the pages on my website built with Rails. See the full stack trace below. If I change false to true in production.rb at line config.cache_classes = false then the problem goes away, but I have to restart the Rails server every time I make a change to any file. It seems like the problem is related to checking the type of a column in my DB, but I can't figure out how to resolve it. Controller action: def manage @view_data = {} if (@view_data

new Date('2016-10-31') returning Sun Oct 30 2016

假装没事ソ 提交于 2020-01-03 17:12:02
问题 I'm in the Azores islands and yesterday (30 October 2016) the timezone has changed from GMT+0000 (AZOST) to GMT-0100 (AZOT). Now new Date('2016-10-31') is returning Sun Oct 30 2016 23:00:00 GMT-0100 (AZOT) : Is this the correct behaviour from the JavaScript Date object? I was expecting the output to be Mon Oct 31 2016... 回答1: From this documentation (emphasis mine): Note: parsing of date strings with the Date constructor (and Date.parse, they are equivalent) is strongly discouraged due to

new Date('2016-10-31') returning Sun Oct 30 2016

元气小坏坏 提交于 2020-01-03 17:10:27
问题 I'm in the Azores islands and yesterday (30 October 2016) the timezone has changed from GMT+0000 (AZOST) to GMT-0100 (AZOT). Now new Date('2016-10-31') is returning Sun Oct 30 2016 23:00:00 GMT-0100 (AZOT) : Is this the correct behaviour from the JavaScript Date object? I was expecting the output to be Mon Oct 31 2016... 回答1: From this documentation (emphasis mine): Note: parsing of date strings with the Date constructor (and Date.parse, they are equivalent) is strongly discouraged due to

Python datetime difference between .localize and tzinfo

混江龙づ霸主 提交于 2020-01-03 15:22:16
问题 Why do these two lines produce different results? >>> import pytz >>> from datetime ipmort datetime >>> local_tz = pytz.timezone("America/Los_Angeles") >>> d1 = local_tz.localize(datetime(2015, 8, 1, 0, 0, 0, 0)) # line 1 >>> d2 = datetime(2015, 8, 1, 0, 0, 0, 0, local_tz) # line 2 >>> d1 == d2 False What's the reason for the difference, and which should I use to localize a datetime? 回答1: When you create d2=datetime(2015, 8, 1, 0, 0, 0, 0, local_tz) in this way. It does not handle daylight

Python datetime difference between .localize and tzinfo

泄露秘密 提交于 2020-01-03 15:20:34
问题 Why do these two lines produce different results? >>> import pytz >>> from datetime ipmort datetime >>> local_tz = pytz.timezone("America/Los_Angeles") >>> d1 = local_tz.localize(datetime(2015, 8, 1, 0, 0, 0, 0)) # line 1 >>> d2 = datetime(2015, 8, 1, 0, 0, 0, 0, local_tz) # line 2 >>> d1 == d2 False What's the reason for the difference, and which should I use to localize a datetime? 回答1: When you create d2=datetime(2015, 8, 1, 0, 0, 0, 0, local_tz) in this way. It does not handle daylight