Skip to content

Instantly share code, notes, and snippets.

@danielpunkass
Created May 26, 2015 16:59
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/d478448dc6d1832b2aac to your computer and use it in GitHub Desktop.
Save danielpunkass/d478448dc6d1832b2aac to your computer and use it in GitHub Desktop.
Example exercising NSDateFormatter with default locale
#!/usr/bin/python
from Foundation import *
form = NSDateFormatter.alloc().init()
form.setFormatterBehavior_(1040)
form.setDateFormat_("yyyyMMdd'T'HH:mm:ss'Z")
form.setTimeZone_(NSTimeZone.timeZoneForSecondsFromGMT_(0))
print "Implied locale is " + NSLocale.currentLocale().localeIdentifier()
print form.stringFromDate_(NSDate.date())
# For one of my users, the equivalent of above seems to print
# as 12-hour time e.g.:
#
# 20160525T7:09:43 pmZ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment