pDate :: X.Element -> ElementParser (Element a)
pDate node = do
  let attr = getAttributes node
  let formatting = getFormatting attr
  let form = lookupAttribute "form" attr
  let var = toVariable $ fromMaybe mempty $ lookupAttribute "variable" attr
  let showDateParts = case lookupAttribute "date-parts" attr of
                        Just "year-month-day" -> Just YearMonthDay
                        Just "year-month"     -> Just YearMonth
                        Just "year"           -> Just Year
                        _                     -> Nothing

  dps <- mapM parseDatePartElement (getChildren "date-part" node)
  let dateType = case form of
                      Just "numeric" -> LocalizedNumeric
                      Just "text"    -> LocalizedText
                      _              -> NonLocalized
  return $ Element (EDate var dateType showDateParts dps) formatting
pDate :: X.Element -> ElementParser (Element a)
pDate node = do
  let attr = getAttributes node
  let formatting = getFormatting attr
  let form = lookupAttribute "form" attr
  let var = toVariable $ fromMaybe mempty $ lookupAttribute "variable" attr
  let showDateParts = case lookupAttribute "date-parts" attr of
                        Just "year-month-day" -> Just YearMonthDay
                        Just "year-month"     -> Just YearMonth
                        Just "year"           -> Just Year
                        _                     -> Nothing

  dps <- mapM parseDatePartElement (getChildren "date-part" node)
  let dateType = case form of
                      Just "numeric" -> LocalizedNumeric
                      Just "text"    -> LocalizedText
                      _              -> NonLocalized
  return $ Element (EDate var dateType showDateParts dps) formatting
pDate node = do
  let attr = getAttributes node
  let formatting = getFormatting attr
  let form = lookupAttribute "form" attr
  let var = toVariable $ fromMaybe mempty $ lookupAttribute "variable" attr
  let showDateParts = case lookupAttribute "date-parts" attr of
                        Just "year-month-day" -> Just YearMonthDay
                        Just "year-month"     -> Just YearMonth
                        Just "year"           -> Just Year
                        _                     -> Nothing

  dps <- mapM parseDatePartElement (getChildren "date-part" node)
  let dateType = case form of
                      Just "numeric" -> LocalizedNumeric
                      Just "text"    -> LocalizedText
                      _              -> NonLocalized
  return $ Element (EDate var dateType showDateParts dps) formatting