Created
February 20, 2020 17:57
-
-
Save iAmrSalman/23a4da0f1f4fd70c09df04a99f77a6d0 to your computer and use it in GitHub Desktop.
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
func attributedString(for type: DateType, with date: Date) -> NSAttributedString { | |
let formatter = DateFormatter() | |
formatter.locale = Locale(identifier: "ar_EG") | |
formatter.dateFormat = "dd\nMMM\nyyyy" | |
if type == .hijri { | |
formatter.calendar = Calendar(identifier: .islamicCivil) | |
} | |
var formattedDate = formatter.string(from: date) | |
formattedDate += "\(type == . hijri ? "هـ" : "م")" | |
let attributedString = NSMutableAttributedString(string: formattedDate, attributes: [ | |
NSAttributedString.Key.font : UIFont.systemFont(ofSize: 18), | |
NSAttributedString.Key.foregroundColor : .black | |
]) | |
return attributedString | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment