Skip to content

Instantly share code, notes, and snippets.

@danielpunkass
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielpunkass/ae9b11e635f6d539b6b5 to your computer and use it in GitHub Desktop.
Save danielpunkass/ae9b11e635f6d539b6b5 to your computer and use it in GitHub Desktop.
Example of NSDateformatter behaving unexpectedly
#!/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