I wish to add the era to a date string formatted by Swift's DateFormatter
in a locale-sensitive fashion (e.g. "6 Shevat 5780 AM"). I know that I can do:
func dateString(calendar: Calendar, date: Date = Date()) -> String {
let df = DateFormatter()
// EITHER
df.dateStyle = .full // Locale sensitive, but does not include (current) era
df.timeStyle = .none
// OR
df.dateFormat = "d MMMM yyyy G" // Not locale sensitive
df.calendar = calendar
return df.string(from: date)
}
...but one way doesn't include the era, the other presumes a date month year ordering.
Any clues, anyone?