Created
August 8, 2014 19:07
-
-
Save SlaunchaMan/550b19c83cdb0e0802db to your computer and use it in GitHub Desktop.
New Formatters in iOS 8
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
| import UIKit | |
| var componentsFormatter = NSDateComponentsFormatter() | |
| componentsFormatter.unitsStyle = .Abbreviated | |
| var components = NSDateComponents() | |
| components.hour = 1 | |
| components.day = 5 | |
| components.year = 1 | |
| var formattedComponents = componentsFormatter.stringFromDateComponents(components) | |
| var intervalFormatter = NSDateIntervalFormatter() | |
| intervalFormatter.dateStyle = .NoStyle | |
| intervalFormatter.timeStyle = .ShortStyle | |
| var currentDate = NSDate() | |
| var future = currentDate.dateByAddingTimeInterval(10_000) | |
| var formattedInterval = intervalFormatter.stringFromDate(currentDate, toDate: future) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment