Add launch arguments for setting timezone

Originator:eli.j.perkins
Number:rdar://25290370 Date Originated:22-Mar-2016 10:25 AM
Status:Open Resolved:
Product:Developer Tools Product Version:
Classification:Enhancement Reproducible:
 
Summary:
Testing formatting of dates doesn't lend itself to easy testing without exposing the API of NSDateFormatter or your code's internals. This leads to poor API design only for the sake of testability.

Launch arguments such as -AppleLanguages and -AppleLocale exist to change the language and region of a specific scheme in Xcode, as seen here https://developer.apple.com/library/ios/documentation/MacOSX/Conceptual/BPInternational/TestingYourInternationalApp/TestingYourInternationalApp.html#//apple_ref/doc/uid/10000171i-CH7-SW2. Nothing exists to modify only the timezone that the scheme is being run in. This seems to rely on the time of the machine running the simulator and does not lend itself to be easily tested in an Xcode XCTest suite.

Consider adding a time zone launch argument that will modify the simulator to set it's timezone to the supplied setting.

Steps to Reproduce:
1. Write test to test localized string for a date using NSDateFormatter.
2. Supply NSDate as value to be tested in locales.
3. Realize that if your tests run in a timezone other than your local machine, your tests will fail.
4. `git push` and CI runs.

Expected Results:
1. Write test to test localized string for a date using NSDateFormatter.
2. Supply NSDate as value to be tested in locales.
3. Supply -AppleTimezone "-08:00" or "America/Los_Angeles" as a localized timezone parameter.
4. `git push` and CI runs.
5. Watch your tests pass!

Actual Results:
Watch your tests fail as there is no way for Xcode to change the timezone of the local machine.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!