-1

What is the difference between "MMMM" and "LLLL" with DateFormatter, specifically for setting localized locales? They are yielding the same result.

MMMM

let dateFormatter = DateFormatter()
dateFormatter.setLocalizedDateFormatFromTemplate("MMMM")
dateFormatter.string(from: Date()) // April

LLLL

let dateFormatter2 = DateFormatter()
dateFormatter2.setLocalizedDateFormatFromTemplate("LLLL")
dateFormatter2.string(from: Date()) // April
craft
  • 1,709
  • 1
  • 17
  • 27
  • 1
    According to the doc (http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_Patterns), `L` is for stand alone. You need to understand what means "Stand alone": `The most important distinction to make between format and stand-alone forms is a grammatical distinction, for languages that require it. For example, many languages require that a month name without an associated day number be in the basic nominative form, while a month name with an associated day number should be in a different grammatical form: genitive, partitive, [...] capitalization....` – Larme Apr 12 '22 at 21:17
  • 1
    In other words the correct choice there is `L` because it is the only date component (stand-alone) in your date format. – Leo Dabus Apr 13 '22 at 03:42
  • Thanks all for the helpful suggestions. @LeoDabus - thanks for the simplification and that answers my question. – craft Apr 13 '22 at 17:48

0 Answers0