-
Notifications
You must be signed in to change notification settings - Fork 39
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
Detect time zone based on IP address #36
Comments
This sounds like a good idea to me, happy to receive a pull request. I suggest it be an optional feature given the dependency on an external service. |
@adamcharnock Hi Adam, Can I do this if there is no one to solve this? |
Hey @NohSeho, that would be great, please go ahead. I suggest two was to implement this, and I'll be happy with either: 1. Simple settingA simple setting such as 2. A pluggable systemA setting such as class TimezoneDetectionDetector(object): # Base class in tz_detect/apis/__init__.py
def get_timezone_offset():
raise NotImplementedError()
# In tz_detect/apis/ipapi.py
class IpApi(TimezoneDetectionDetector):
def get_timezone_offset(self, request):
offset_minutes = ...
return offset_minutes
The benefit of this system is it allows others to create custom detectors, and also allows us to provide multiple implementations. The downside is that it is more of a faff to write. Definitely feel free to choose option 1 should you prefer, it can always be refactored into option 2 at a later date should the need arise. Also, tagging @bashu in case of any additional comments. |
Oh, you already design the system. That's cool. but I don't know how I spend my time for this. Please take your time. |
My apologies @NohSeho, these were only my initial thoughts in the last 20 minutes, my intention was to start a discussion. I find discussing the implementation in advance can save time. I should have been clearer about this. Equally, if you just want to get started on an implementation then I am very happy for you to do so, and I'll look over whatever you come up with. I still don't have time to work on this, so contributions are still very welcome. |
No problem. but I just want to clarify one. I saw above @adamcharnock you and @bigblind 's comments and the ip-api.com website, that means, Fully using ip-api.com needs a pricing and we are going to implement that API just for an option, not required. right? |
Hi @NohSeho, correct. I think it should be optional and (probably) not enabled by default. |
Great, I got it. |
@NohSeho Can't wait for your idea implemented! :) |
@gotexis Calm down :) |
I vote against this whole idea. In fact all Russia use anonymizer proxy to bypass the Telegram ban. User would be located in Central Europe instead of Ural. Also true for all Internet access controlling countries. |
You make an excellent point @denis-trofimov, thank you. I therefore stand by my original comment that this should be an optional feature. This is on the grounds that:
My above comment shows a couple of ways in which to achieve this. Just to be clear: I think this feature is very valuable and I encourage anyone to implement it. Even valuable features need to be optional sometimes :-) |
There's an API called ip-api.com which will give you the location and time zone based on the user's IP.
If we use this on the server side, we can get the time zone in the first request. This does come at a performance cost, because network requests take time, so this should definitely be a setting. Also, the free tier only allows you to make 150 requests/minute, which might be too few for high-traffic apps, although you'd need to have a lot of unique visitors per minute, since we're only making one api request per user session.
This would also solve the time zone change detection problem (#25). We could detect a change in the user's ip, and make another request to the time zone service.
If this sounds like a good idea, I'm willing to submit a pull request.
The text was updated successfully, but these errors were encountered: