Rails time zones - ruby-on-rails

I'm calling an external web service API that returns a timezone as listed in the Olson timezones database (e.g. "America/New_York"). However some of the values the API returned are "US/Pacific", "US/Eastern" and apparently don't match any of the Olson timezones in Rails 2.3.2. Can anyone shed some light on this? Thanks in advance for your help.

I don't know why they're being returned by the particular API you're using, but those entries do exist in the PHP timezone implementation (and maybe others), with the warning "Please do not use any of the timezones listed here (besides UTC), they only exist for backward compatible reasons."
I guess Rails uses a stricter implementation.

Related

Obtain timezone of a Google Analytics 4 property?

There doesn't seem to be a way to obtain the timezone of a Google Analytics property, or is there?
The Data API (https://developers.google.com/analytics/devguides/reporting/data/v1/api-schema?hl=en) returns data in the property's timezone but in order for us to interpret it correctly we need to know what timezone the property is in.
Has anyone found a workaround?
Thanks!
The Data API is for reporting purpose only.
For property and other GA related configurations, Admin API should be used.
Here is the property.get method, the response of which has timeZone in it.
The Data API responses now contain a metadata object with "currencyCode" and "timeZone" strings. This is a part of an example response:
More documentation on these fields will come out soon, and these fields will be available in the client libraries (i.e. python) soon.
Thanks, Brett
The Google Analytics Team
In addition to using the Data API response metadata, it is possible to use the Admin API properties.get method to obtain the property's timezone.

What database does Maxmind use for timezone IDs?

I'm using Maxmind's GeoIP2 products to extract timezone IDs and then using JodaTime to parse/manipulate those timezones. I've noticed that there are timezones that are returned form GeoIP2 that are not in JodaTime's available list of timezones, such as "Europe/Kirov"
I'd like to properly parse all timezones, but without insight into what timezone database/directory Maxmind is using, I don't know how to begin. Does anyone know what they're using?
MaxMind pulls the geographical data in GeoIP2 from GeoNames, which uses the IANA Time Zone Database. See this file for Europe/Kirov. This entry was added in the 2016d release of the IANA database. JodaTime 2.9.4 should include it.

Google Geocoding API error: over query limit. - Rails

I know this question has been asked but most answers were a few years old and not all for a Ruby on Rails project. In my current project, I am using the Geocode gem (via Ruby on Rails) and anyone is able to search users by their location (which I also use the Carmen gem for country, subregion).
Anyway, I've been receiving this issue lately (Google Geocoding API error: over query limit.). After reading up on it, I see that this is quite common. Most of the resolutions seem to involve caching but others say that it does not work much/well.
I wanted to pose the question to many here and see what various people think is a good resolution. Ideally it would be great to keep the Geocoding gem within the project, but if it is not worth it, please let me know of an alternative. If you know of a resolution to this issue, please let me know too.
Thank you and simply looking to receive feedback for this situation =)
PS: I do not use the Google Maps API. The project is setup so that a user enters their information (using Carmen gem) and typing the cit. The location is geocoded and others can type in a city, state/region to find users within that region.
EDIT
Additional Question: When this limit is met, would that also cause the longitude and latitude value to be nil when a user signs up? Since it is as the limit, it will not geocode the location entered and so it keeps the value at nil? I've had this happen before so I just want to make sure this is why =P
EDIT 2 - ANSWER?
After speaking a bit (in comments below), it seems the best option is to cache the information. With that being said, after researching I see that there are a lot of legalities when it comes to caching with google? Again I do not use the Google Map API so the legal aspect may not be relevant?
Would this be a good solution to implementing the cache (https://github.com/codeforamerica/ohana-api/wiki/Customizing-the-geocoding-configuration)?
Just want to make sure I implement the cache aspect properly =P Thanks!
Joe
ANSWER
So after some research and help from japed (see comments above), I found this documentation (https://github.com/codeforamerica/ohana-api/wiki/Customizing-the-geocoding-configuration) which clearly explained how to setup Redis with Geocoding for caching purposes. It also provided another link with more information to test it in development before deploy.
Thank you!
Joe

Finding local time zones in rails

I'm wondering if there is an easy way to look up a user's local time zone in Rails using only an IP address. I don't want users to have to input their time zone themselves. Do I have to use JavaScript or is there a different way?
The maxmind GeoLite IP->city database seems to support timezones and there's a FAQ on their site referring to this. You could either do a two-step process of IP->Location then Location->timezone using the Maxmind GeoLite City database and then use one of the solutions provided in the FAQ.
Or for a simple 1-step javascript, using getTimezoneOffset() seems to be the crux of the solution.
There appear to be several vendors offering APIs and callable services to go from ip address to location, and clearly once you have that determining the timezone is only a further lookup.
Your alternative of using javascript to ask the browser "where am I, what's the time zone" and Ajaxing that down to your server also sounds plausible.
Of course a sufficiently determined user can probably spoof their way to appearing to be at a different ip address, but presumably that doesn't matter too much to you ... their choice.
you can use the ip address-to-time API to find time by IP address.
Look here http://worldtimeengine.com/ for more details.
Dan

All Countries States Cities and Zipcodes in a Application

Is there a way getting all countries, states,cities zipcodes/ in one single database.
I have been looking all over.
I discovered geonames.org, which has I guess all of the content. But there is no way to fetch that data directly.
I am using rails. If there any helpers or Plugins, it'd be great. It would be awesome if there is a complete resource in any parsable format which I can use to get this database in place.
Please recommend if you any thanks
I do have the iso country code list but no States for some countries.
Thanks in advance
Thanks Guys,
I got all the the countries and states of all of them, but no zip codes.
http://27.org/isocountrylist/iso_country_list.sql
This contains all countries, and there iso-3166 codes ( Siberia code needs to be changed from "CS" to "RS")
And here is the FIPS file for countries with states
http://www.maxmind.com/app/fips_include
For zip code validation I am using
http://www.geonames.org webservices
There is a geonames ruby gem as well, which makes it really simple to do zipcode validations
Hope that helps anybody who needs this information, worth keeping it handy for web projects.
Another Link ( thanks #laise ): http://dev.maxmind.com/static/csv/codes/maxmind/region.csv
The Carmen plugin is almost certainly what you're looking for.
This will take a little legwork and data munging, but it's not too bad.
Countries and country codes are easy to come by. Sounds like you already have them.
Not all countries are divided into states. You may have to simply address these one by one-- there may be some combined reference, but not that I know of.
U.S. cities are available, and look for things like FIPS codes. There are commercial data providers that will provide you clean, well-organized data, but they are charging for it.
The post office has some databases with all the zip codes. Note that these charge periodically, and a single zip code doesn't imply a single single (far from it!). And it may not be necessary to actually have a database of all of them, as there are zip verification/correction services available for free.
For loading the data, check out a recent railscast on the subject.
I was looking for the same and found this resource. I hope somebody serves well as me.
http://dev.mysql.com/doc/world-setup/en/index.html
For those using the FIPS 10-4/FIPS 5-2 standard, I have been maintaining the NGA GEC (formerly FIPS 10-4/5-2) Excel spreadsheet (original format) for 1st level administrative divisions of countries. The spreadsheet is currently updated to Update 15 (March 2014):
http://www.opengeocode.org/archive.php

Resources