I can't seem to find if I need to have the location services prompt if I'm just using the timezone? I've turned off location services on my phone while testing and it still finds my timezone with it off. I just don't want to be rejected by apple.
I'm using this:
var timeZone = NSTimeZone.localTimeZone().name
Thanks for any help.
Keith
No. You will never get a prompt for localtimezone which is used by default when creating your NSDate objects. BTW you are not defining any timeZone like this you are only assigning the name of the local timezone to a var.
If you need some more info regarding time zones you should take a look at this link:
using NSTimeZone framework
Related
When using the localtime method on a UTC Time object, is the time returned the local time as specified in the app configuration or the local time of the user's location?
localtime will give you the time in the current time zone of the machine running the code.
Apidock(localtime): for ruby, ruby on rails
.localtime in your app will show your app's time. To display localtime to different users you will need to add some Javascript.
This answer might help you.
How to display the time in user's timezone
I have a really simple question and couldn't find the answer about. Is it possible to change the jenkins timestamp according to the user's browser timezone. As my Jenkins server is in UTC but some of our users are in Central timezone while other are in few different timezones. So I want that they see the task(s) timestamp according to their browser time/timezone. How we can achieve this? Thanks
One possible approach for this could be to deliver all dates in a default timezone and use momentjs or a similar library to convert the date time on the frontend side to either the browsers timezone (this could be the default) or to a manually selected one.
This would be rather easy to implement and would not require any big changes in jenkins itself, just all places that deliver times must be wrapped in some markup, e.g. a class and some data-fields (e.g. data-datetime containing an rfc3339 timestamp)
Jenkins issues JENKINS-19887 and JENKINS-1962 detail potential fixes that could be introduced, though they haven't been implemented in any version of the system yet.
If you're only looking for timestamps with the browser's time zone in your console output (with all other timestamps unmodified), Timestamper provides this functionality.
I am in the process of developing SMS based app. When my app launches I select the last-message-date-time from database and send it to the server and I get back all the messages with date-time > last-message-date-time but because the app and server may not be in the same timezone I can't get the correct result. What is the best way to fix this issue? Please help. Thank you.
This question is the follow up of update SQLite with content of push notification when the app is not running.
One of the options is to store the time stamp in UTC/GMT on server, and when you get the date from server, convert it to local date object using GMT as formate, then show the user to their local timezone using formatters. ie.
Store the date in UTC/GMT on server.
Get the date string in app, use NSDateFormatter with GMT/UTC as timezone to convert it to NSDate object in Objective-C
Use NSDateFormatter with local timezone to show it to user.
Keep in mind that NSDate holds the date as independent of timezones so when showing it to user, use any NSDateFormatter to convert it to local or any timezone.
Here's apple's guide to managing timezones: Using Time Zones
A useful discussion here: A Fast, Accurate Way to Handle Dates from Servers
Please first convert your system's timezone to your server's timezone when you select date-time from database then send it to server.
To figure out this issue. you need to follow the following steps.
Step 1 : Always keep server time zone in UTC.
Step 2 : once you need to send Date-time to server. first need to convert it to UTC and then send to server so server stored it.
Step 3 : While fetching Date-Time from server, you need convert it with respected Time Zone. where you currently are. like if i am using app from INDIA then i will add +5:30 in receiving date from server. so all country manage same.
Hope this help you
So the original requirements was that on the launch of the app, the mobile app will get the current location of the user precise to City. Based on the city, the server/app client will give-city related content.
I know it would not be too difficult if I could use the core location service (since you know suspicious (self-concerned) users usually will disable the location service for a not-so-trusting app).
I have searched the web for few hours and get an summary of following solutions where I need your help to decide which one could be my best option or if you have any other better ones.
Using the [NSlocale autoupdatingCurrentLocale]
cons:
a.The explanation of the return value of the call from apple's document: "The locale is formed from the settings for the current user’s chosen system locale overlaid with any custom settings the user has specified in System Preferences." From which I don't understand what is "custom settings the user has specified in System Preferences"
reference link
b. This value could be misleading and not related with user's actual current city/country at all.
comments: I would be appreciated if anybody could explain me how the locale is changed according to user's setting.
Getting the current iPhone TimeZone
NSTimeZone *localTime = [NSTimeZone systemTimeZone];
NSLog(#"Current local timezone is %#",[localTime name]);
cons:
a. same as item b above, because user can always specify rather than let the system auto update the time zone.
b. precision is comprimised, only capital city will be listed.
comments:Not very promising but easy to implement
Using IP based location detection webservice
Based on my reading, the process will involve the app sending a request to a server where the server will record the IP of the request.(Don't think from App itself could get its own IP correctly since it may inside a local network) Based on the IP recorded through some third party service (with a IP db or some other available APIs), it will return the city information back to the client.
cons:
a. I've never implemented such thing, don't know if it is feasible for a mobile app.
b. Even if it is possible, don't know if it is faster than the core location service.
comments: If you know it is possible for a iOS app to do so please let me know.
Please kindly give me any thoughts you have or suggest any better solution if you know.
Thank you very much.
A preventive measure to avoid all your trouble would be to create an app that wouldn't appear 'not-so-trusting' and use core location to get the location. If a user still does not allow your app to know the location and knowing his city is a must, let him select a city from the list of cites for which content is available. Of course this opens up a huge hole allowing use to get the content for ANY city. Only you can decide if this is an acceptable tradeoff for simpler implementation.
If you must know the CITY automatically without core location, the first two options you mentioned, 'locale' and 'time zone' are useless as each of them encompasses large number of cities. Also, as you mentioned they're dependent on user's settings.
So reverse geocoding the IP address of a web service request using GeoIP or some such service is your best bet. You can find a lot of discussion and references for this on the web.
NSlocale can be highly inaccurate. My colleague bought the iPhone from New Zealand (he was studying there). When I am testing his phone to get the locale for language, it still show as New Zealand English.
Using IP is possible. I made a quick search and I found:-
Find IP address in iphone
how to get ip address of iphone programmatically
You might want to take a good read from above links.
I still think using Core Location is the best way to get the location of the user.
In my rails application,After login a user has to create a timesheet entry.The time of creation of the entry is currently my server time.Whereas i want it to be the time of the timezone from where the entry is made i.e if entry is made from any other country.I'm using rails 3 and after searching the web also exact solution cannot be achieved.
Thanx
You can't automatically determine the user's timezone, but you can allow them to choose their own timezone. Then you can set Time.zone = ActiveSupport::TimeZone(offset) before calling update and everything should work correctly. You could also save each user's preference for time zone in your user model.
I'm not sure if it's possible to do this in Rails as the issue is getting the physical location of a user.
It may be worth using JavaScript to populate a (hidden?) field with the current time, which should be taken from user's local machine. You could then explicitly set the created_at field to be this value.
Intrigued to know if Rails can get around this somehow...
If you want, take a look to this question : transform time into local time in Ruby on Rails
And : http://www.wetware.co.nz/blog/2009/07/rails-date-formats-strftime/
Maybe it can helps you.