Created
October 15, 2016 09:21
-
-
Save bananafish911/0c739f379443b87dd6db59274f652d07 to your computer and use it in GitHub Desktop.
This file contains 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 Date { | |
/// For application labels | |
func toStringAppFormatted() -> String { | |
let components = NSCalendar.current.dateComponents([Calendar.Component.day, | |
Calendar.Component.month, | |
Calendar.Component.year], | |
from: self) | |
return "\(components.day!).\(components.month!).\(components.year!)" | |
} | |
/// get local time | |
func toHoursMinutesString() -> String { | |
let components = NSCalendar.current.dateComponents([Calendar.Component.hour, | |
Calendar.Component.minute], | |
from: self) | |
return String(format: "%02d:%02d", components.hour!, components.minute!) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment