I've been looking for a while now and have done a good amount of research as well as experimenting, but I cannot find a way to retrieve the value stored in a users settings for Time Zone Support on iOS devices.
I have looked into NSTimeZone convenience methods +systemTimeZone, +resetSystemTimeZone, +defaultTimeZone, +localTimeZone. I even fully understand the differences between them and how we can set our own default time zone per application, and how first call to default returns value for system. System then gets cached and needs to be reset if the device changes time zones.
Problem is, systemTimeZone is always where the device is actually located, not the value set in the device's settings under Time Zone Support.
I have even looking into [[NSCalendar currentCalendar] timeZone] as well as [[NSCalendar autoupdatingCurrentCalendar] timeZone]].
I even tried [[[NSLocale currentLocale] objectForKey:NSCurrentCalendar] timeZone] and [[[NSLocale autoupdatingCurrentLocale] objectForKey:NSCurrentCalendar] timeZone]
Nothing returns the value of the device's Settings.app -> Mail, Contacts, Calendars -> Time Zone Support -> Time Zone.
Does anyone know how to retrieve the value of the Settings.app -> Mail, Contacts, Calendars -> Time Zone Support -> Time Zone setting?
Thanks and Cheers!
Forgive me if this is way off the mark, but are you sure that you actually want to access the Time Zone Support setting from the following location?
Settings.app -> Mail, Contacts, Calendars -> Time Zone Support
I would not have made this post otherwise, but you got me thinking when you stated the following:
Problem is, systemTimeZone is always where the device is actually located, not the value set in the device's settings under Time Zone Support.
Unfortunately, your statement here is not quite correct. +systemTimeZone will return the time zone for where the device is actually located unless the user has turned off Set Automatically and chosen a particular time zone at the following location:
Settings.app -> General -> Date & Time
This will change the time zone to be used system-wide, which is immediately reflected by the time in the status bar adjusting for the new setting.
What you have been trying access previously seems focused on how calendar appointments are represented in the native Calendar.app, and would appear to be private to that application (along with the rest of the settings in that area).
If you are looking for access to the effective system-wide time zone setting that can be modified by the user then Time Zone under Date & Time is the way to go. This will be the value returned by +systemTimeZone.
On the other hand if you really must access the Time Zone Support setting under Mail, Contacts, Calendars I'm afraid I cannot help you and I apologise for the distraction.
Related
I'm an amateur photographer. I have Video, Mobile, Camera, Drone, etc. My goal is to sync all data on the right time and add GPS tag.
I end on configure everything on UTC (except mobile), and add after GPS tag that is on UTC also.
Main problem is how to determine correct timezone based on where the picture has been taken, and if I have to, since all my mobile photos has the timezone (and daylight savings) applied when taking video/photo.
I'm using now an OPEN API for having the correct GMT based on the geolocation and time/date.
Am I doing it right? Am I interpretating DATE/TIME changes correctly? I saw after that Lightroom changes based on the date/time info and the place it's used (photos).
It's a mess.
I have an application in Vuejs (Typescript) that get date from User, I am facing two issues for the time being.
Every time the User enter date of birth system decreases one.
If user enter 03/05/1981 and the System date formate is MM/dd/yyyy it store 5th of March.
I can't tell every person to change format to dd/MM/yyyy, or is there a way around.
Thanks
By the details you have provided I assume everything happens in the browser.
Please check your browser localization settings even if your computer localization is setup as US if the browser has a different setting then it will be overwritten.
If you are sending the information to a different server please check how are you formatting the date in your request and which are the server side settings about localization.
Hope this helps.
Integrated Amazon Product Advisement API with my own application, It's working fine but the problem is:
To access the API we need time stamp, when I put the code on the server ( which is in other country), and used the server time stamp, then API gave the following error in the XML: "Request has expired. Timestamp date is XXXX-XX-XXTXX:XX:XXZ",
but when I enter my own time zone where currently I am, then its start working fine. Why API is working fine with client side timestamp, on the other hand all calculation related to API are happening on the server side.
I consult the following Developer document of Amazon API, but no avial.
Product Advertising API Developer GuideAPI Version 2011-08-01
var currentdate = new Date();
currentdate.toISOString();
This is how I got the time stamp for Product Advertising Api.
I consult the following Developer document of Amazon API, but no avial. Product Advertising API Developer GuideAPI Version 2011-08-01
Hum, this document clearly state the Timestamp parameter MUST be represented in Universal Time (UTC); You cannot send a local time, unless, by chance (which might be the case for your personal location) you happen to be on the same time as UTC:
"• Timestamp—Required. There is no default value. The time stamp you use in the request must be a
dateTime object, with the complete date plus hours, minutes, and seconds (for more information, go
to http://www.w3.org/TR/NOTE-datetime).This is a fixed -length subset of the format defined by ISO
8601, represented in Universal Time (GMT): YYYY-MM-DDThh:mm:ssZ (where T and Z are literals).
Important
If you are using .NET you must not send overly specific time stamps, due to different
interpretations of how extra time precision should be dropped. To avoid overly specific time
stamps, manually construct dateTime objects with no more than millisecond precision."
I have an IOS app that needs to track duration of free usage per day. Once it crosses a threshold, the user would have to purchase the app or wait for the next day to unlock his free-usage minutes for that day.
Is there a native way to detect if the user has set his clock back? Assume there is no Internet connection to sync with a time server
UIApplicationDelegate can get the following method called on significant time changes:
- (void)applicationSignificantTimeChange:(UIApplication *)application
You can try that one. From my point of view, I'd recommend to check current date on every application launch or willBecomeActive and store those dates as list somewhere securely. If current date is different from the last date, add it to your list. If list has more than 30 items (or how many you need) disable trial functionality.
I'm looking for an example where + autoupdatingCurrentCalendar would be used instead of + currentCalendar. More specifically where the values based on the calendar are automatically changed when the calendar changes. Do I need bindings for this or something like that?
The docs state:
Note that if you cache values based on
the calendar or related information
those caches will of course not be
automatically updated by the updating
of the calendar object.
Thanks in advance
currentCalendar returns cached version of current system calendar, while autoupdatingCurrentCalendar always returns most recent version of system calendar.
That is important, when you are presenting data based on the various parameters of a calendar like number of days in a month, number of a weeks in year or number of hours in a day.
To be honest, I don't know why Apple gives you an opportunity to get outdated value by using currentCalendar.
It looks like they have internal API that allows you to manipulate caches of NSCalendar, so you can achieve better performance. But since it is not public, there is no reason to use currentCalendar.
That is, always use autoupdatingCurrentCalendar.
Well, on OS X you can be running multiple processes simultaneous. One could be your process that uses the autoupdatingCurrentCalendar. The other could be System Preferences.
System Preferences allows you to customize your calendar settings. You can choose the first day of the week to be something other than the default (Sunday). Or you can choose a whole different calendar altogether. If you use the autoupdatingCurrentCalendar, these changes will be picked up automatically. If you don't use it, they won't.
I guess that it is only usefull if you store the calendar in memory for further use. Doing that way, if the calendar settings change, your stored calendar will take account of those changes if you used autoupdatingCurrentCalendar. If you only used currentCalendar, it wil stay at the state it was at your first call.