DayPeriodFormatter icon indicating copy to clipboard operation
DayPeriodFormatter copied to clipboard

Add Property to Ignore Fixed Periods

Open mattt opened this issue 4 years ago • 0 comments

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.

mattt avatar Jul 25 '19 14:07 mattt