parseDatePartElement :: X.Element -> ElementParser DP
parseDatePartElement node = do
  let attr = getAttributes node
  let formatting = getFormatting attr
  let name = case lookupAttribute "name" attr of
               Just "day"   -> DPDay
               Just "month" -> DPMonth
               _            -> DPYear
  let form = case lookupAttribute "form" attr of
               Just "numeric"                -> DPNumeric
               Just "numeric-leading-zeros"  -> DPNumericLeadingZeros
               Just "ordinal"                -> DPOrdinal
               Just "long"                   -> DPLong
               Just "short"                  -> DPShort
               _ | name == DPDay             -> DPNumeric
                 | otherwise                 -> DPLong
  let rangeDelim = fromMaybe "–" $ lookupAttribute "range-delimiter" attr
  return $ DP name form rangeDelim formatting


parseDatePartElement :: X.Element -> ElementParser DP
parseDatePartElement node = do
  let attr = getAttributes node
  let formatting = getFormatting attr
  let name = case lookupAttribute "name" attr of
               Just "day"   -> DPDay
               Just "month" -> DPMonth
               _            -> DPYear
  let form = case lookupAttribute "form" attr of
               Just "numeric"                -> DPNumeric
               Just "numeric-leading-zeros"  -> DPNumericLeadingZeros
               Just "ordinal"                -> DPOrdinal
               Just "long"                   -> DPLong
               Just "short"                  -> DPShort
               _ | name == DPDay             -> DPNumeric
                 | otherwise                 -> DPLong
  let rangeDelim = fromMaybe "–" $ lookupAttribute "range-delimiter" attr
  return $ DP name form rangeDelim formatting
parseDatePartElement node = do
  let attr = getAttributes node
  let formatting = getFormatting attr
  let name = case lookupAttribute "name" attr of
               Just "day"   -> DPDay
               Just "month" -> DPMonth
               _            -> DPYear
  let form = case lookupAttribute "form" attr of
               Just "numeric"                -> DPNumeric
               Just "numeric-leading-zeros"  -> DPNumericLeadingZeros
               Just "ordinal"                -> DPOrdinal
               Just "long"                   -> DPLong
               Just "short"                  -> DPShort
               _ | name == DPDay             -> DPNumeric
                 | otherwise                 -> DPLong
  let rangeDelim = fromMaybe "–" $ lookupAttribute "range-delimiter" attr
  return $ DP name form rangeDelim formatting