DayPeriodFormatter
DayPeriodFormatter copied to clipboard
Add Property to Ignore Fixed Periods
I could imagine consumers of this library wanting to ignore fixed periods when getting the string for a day period in certain locales. Although I wouldn't necessarily advise this usage, someone might prefix the English language day period with the word "Good" as a greeting to users ("Good morning", "Good afternoon", etc.). Without filtering on fixed periods, this would lead to awkward constructions like "Good noon" and "Good midnight".
Implementation-wise, this would involve the following:
- Adding a new property to
DayPeriodFormatter
(naming is probably the hardest part of this feature) - Updating
DayPeriodRuleSet.period(for:)
to take a second parameter to pass the aforementioned property value to conditionally ignore any fixed period for a given hour.