Created
July 21, 2014 20:08
-
-
Save andrea-ale-sbarra/21ed9c8fa8a4aa4ed8ad to your computer and use it in GitHub Desktop.
Estendere la NSDate in swift e settaggi utili
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
extension NSDate | |
{ | |
convenience | |
init(dateString:String) { | |
let dateStringFormatter = NSDateFormatter() | |
dateStringFormatter.dateFormat = "yyyy-MM-dd" | |
dateStringFormatter.locale = NSLocale(localeIdentifier: "en_US_POSIX") | |
let d = dateStringFormatter.dateFromString(dateString) | |
self.init(timeInterval:0, sinceDate:d) | |
} | |
} | |
Now you can create an NSDate from Swift just by doing: | |
NSDate(dateString:"2014-06-06") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
/*
x number
xx two digit number
xxx abbreviated name
xxxx full name