Skip to content

Commit

Permalink
Remove :format default for Gregorian#formats
Browse files Browse the repository at this point in the history
`:format` is not a valid `type` anyway, so it would never match anyway.

In the `ldml.dtd`:

* For `dateFormatLength`, `timeFormatLength` the `type` attribute is `#REQUIRED`.
* For `dateTimeFormatLength`, `type` attribute is `#IMPLIED`

There are no instances in the code where any of these are missing the `type` attribute.
So while in the future it could technically happen for `dateTimeFormatLength`,
I'd rather the code fail in that case, then silently pass with a nonsense value.
  • Loading branch information
movermeyer committed Nov 15, 2021
1 parent b918afa commit e64c3a1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/cldr/export/data/calendars/gregorian.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ def elements(node, kind, context, width, options = {})
end
end
end

def xpath_to_key(xpath, kind, context, width)
kind = (xpath =~ %r(/([^\/]*)Width) && $1) || kind
context = (xpath =~ %r(Context\[@type='([^\/]*)'\]) && $1) || context
width = (xpath =~ %r(Width\[@type='([^\/]*)'\]) && $1) || width
:"calendars.gregorian.#{kind}s.#{context}.#{width}"
end

def xpath_width
end

Expand Down Expand Up @@ -114,7 +114,7 @@ def extract(path, lambdas)

def formats(type)
formats = select(calendar, "#{type}Formats/#{type}FormatLength").inject({}) do |result, node|
key = node.attribute('type').value.to_sym rescue :format
key = node.attribute('type').value.to_sym
result[key] = pattern(node, type)
result
end
Expand Down Expand Up @@ -162,4 +162,4 @@ def fields
end
end
end
end
end

0 comments on commit e64c3a1

Please sign in to comment.