<commit_before>/* eslint-disable camelcase */
import { EDITORIAL_DETAIL_ACTIONS } from '../../app/pages/EditorialOverviewPage/constants'
import SHARED_CONFIG from '../../shared/services/shared-config/shared-config'
import useSlug from '../../app/utils/useSlug'
import formatDate from '../../shared/services/date-formatter/date-formatter'
import PAGES from '../../app/pages'

const normalizeObject = (data, type) => {
  const {
    uuid,
    title,
    body,
    teaser_url,
    short_title,
    field_teaser,
    intro,
    field_special_type,
    field_publication_date,
    field_publication_year,
    field_publication_month,
    field_file,
    media_image_url,
    ...otherFields
  } = data

  const slug = useSlug(title)

  // The type SPECIALS has a different url structure
  const to =
    type === PAGES.SPECIALS
      ? EDITORIAL_DETAIL_ACTIONS[type](uuid, field_special_type, slug)
      : EDITORIAL_DETAIL_ACTIONS[type](uuid, slug)

  let localeDate = field_publication_date

  let localeDateFormatted = field_publication_date && formatDate(new Date(field_publication_date))

  /**
   * Sometimes we don't get a field_publication_date, but only a field_publication_year and / or field_publication_month
   * Then we need to convert it to a locale date that only shows the year or year and month
   */
  if (!field_publication_date && (field_publication_year || field_publication_month)) {
    localeDate = new Date(
      Date.UTC(field_publication_year, field_publication_month || 1, 1, 0, 0, 0),
    )

    localeDateFormatted = formatDate(
      localeDate,
      false,
      !!field_publication_month,<commit_msg>Fix string date parsing for articles in IE by converting it to the standard iso format<commit_after>/* eslint-disable camelcase */
import { EDITORIAL_DETAIL_ACTIONS } from '../../app/pages/EditorialOverviewPage/constants'
import SHARED_CONFIG from '../../shared/services/shared-config/shared-config'
import useSlug from '../../app/utils/useSlug'
import formatDate from '../../shared/services/date-formatter/date-formatter'
import PAGES from '../../app/pages'

const normalizeObject = (data, type) => {
  const {
    uuid,
    title,
    body,
    teaser_url,
    short_title,
    field_teaser,
    intro,
    field_special_type,
    field_publication_date,
    field_publication_year,
    field_publication_month,
    field_file,
    media_image_url,
    ...otherFields
  } = data

  const slug = useSlug(title)

  // The type SPECIALS has a different url structure
  const to =
    type === PAGES.SPECIALS
      ? EDITORIAL_DETAIL_ACTIONS[type](uuid, field_special_type, slug)
      : EDITORIAL_DETAIL_ACTIONS[type](uuid, slug)

  let localeDate = field_publication_date

  let localeDateFormatted =
    field_publication_date && formatDate(new Date(field_publication_date.replace(' ', 'T')))
  /**
   * Sometimes we don't get a field_publication_date, but only a field_publication_year and / or field_publication_month
   * Then we need to convert it to a locale date that only shows the year or year and month
   */
  if (!field_publication_date && (field_publication_year || field_publication_month)) {
    localeDate = new Date(
      Date.UTC(field_publication_year, field_publication_month || 1, 1, 0, 0, 0),
    )

    localeDateFormatted = formatDate(
      localeDate,
      false,
      !!field_publication_month,
{'fraction_non_alphanumeric': 0.1001788908765653, 'fraction_numerical': 0.0029815146094215863, 'mean_word_length': 3.621212121212121, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3625445', 'n_tokens_mistral': 1077, 'n_tokens_neox': 1036, 'n_words': 259}