Last active
August 29, 2015 14:21
-
-
Save danielpunkass/ae9b11e635f6d539b6b5 to your computer and use it in GitHub Desktop.
Example of NSDateformatter behaving unexpectedly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from Foundation import * | |
form = NSDateFormatter.alloc().init() | |
# Explicit 24 hour time format used to trump any user settings (I think?) | |
form.setDateFormat_("HH:mm:ss") | |
print "Current locale is " + NSLocale.currentLocale().localeIdentifier() | |
print form.stringFromDate_(NSDate.date()) | |
form.setLocale_(NSLocale.localeWithLocaleIdentifier_("en_US")) | |
print "Forcing US English" | |
print form.stringFromDate_(NSDate.date()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment