Skip to content

Commit

Permalink
Fix: Primer::Beta::RelativeTime does not correctly accept "month" att…
Browse files Browse the repository at this point in the history
…ribute (#2408)
  • Loading branch information
HDinger committed Nov 29, 2023
1 parent b4c21dc commit 57586da
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/new-lamps-poke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/view-components': patch
---

Fix: Allow month attribute for Primer::Beta::RelativeTime
8 changes: 4 additions & 4 deletions app/components/primer/beta/relative_time.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class RelativeTime < Primer::Component

MONTH_DEFAULT = nil
MONTH_MAPPINGS = {
DAY_DEFAULT => nil,
MONTH_DEFAULT => nil,
:numeric => "numeric",
:two_digit => "2-digit",
:short => "short",
Expand All @@ -63,15 +63,15 @@ class RelativeTime < Primer::Component

YEAR_DEFAULT = nil
YEAR_MAPPINGS = {
DAY_DEFAULT => nil,
YEAR_DEFAULT => nil,
:numeric => "numeric",
:two_digit => "2-digit"
}.freeze
YEAR_OPTIONS = YEAR_MAPPINGS.keys

TIMEZONENAME_DEFAULT = nil
TIMEZONE_MAPPINGS = {
DAY_DEFAULT => nil,
TIMEZONENAME_DEFAULT => nil,
:long => "long",
:short => "short",
:short_offset => "shortOffset",
Expand Down Expand Up @@ -131,7 +131,7 @@ def initialize(
@system_arguments[:hour] = fetch_or_fallback(HOUR_OPTIONS, hour, HOUR_DEFAULT) if hour.present?
@system_arguments[:weekday] = fetch_or_fallback(WEEKDAY_OPTIONS, weekday, WEEKDAY_DEFAULT) if weekday.present?
@system_arguments[:day] = fetch_or_fallback(DAY_OPTIONS, day, DAY_DEFAULT) if day.present?
@system_arguments[:month] = fetch_or_fallback(MONTH_DEFAULT, month, MONTH_DEFAULT) if month.present?
@system_arguments[:month] = fetch_or_fallback(MONTH_OPTIONS, month, MONTH_DEFAULT) if month.present?
@system_arguments[:year] = fetch_or_fallback(YEAR_OPTIONS, year, YEAR_DEFAULT) if year.present?
@system_arguments[:"time-zone-name"] = fetch_or_fallback(TIMEZONENAME_OPTIONS, time_zone_name, TIMEZONENAME_DEFAULT) if time_zone_name.present?
@system_arguments[:threshold] = threshold if threshold.present?
Expand Down

0 comments on commit 57586da

Please sign in to comment.