<commit_before>const core = require('/data-hub/5/mapping-functions/core.sjs');
const test = require("/test/test-helper.xqy");

function testParseDate() {
  return [
    test.assertTrue(xs.date("2014-01-06").eq(core.parseDate("01/06/2014", "MM/DD/YYYY"))),
    test.assertTrue(xs.date("2014-01-06").eq(core.parseDate("06/01/2014","DD/MM/YYYY"))),
    test.assertTrue(xs.date("2014-01-06").eq(core.parseDate("01.06.2014","MM.DD.YYYY", ))),
    test.assertTrue(xs.date("2014-01-06").eq(core.parseDate("06.01.2014", "DD.MM.YYYY"))),
    test.assertTrue(xs.date("2014-01-06").eq(core.parseDate("20140106", "YYYYMMDD"))),
    test.assertTrue(xs.date("2014-01-06").eq(core.parseDate("Jan 06, 2014", "Mon DD, YYYY")))
  ];
}

function testMoreParseDate() {
  return [
    test.assertEqual(xs.date("2018-01-02"), core.parseDate("01-02-2018", "MM-DD-YYYY")),

    test.assertEqual(xs.date("1996-07-16"), core.parseDate("Jul 16, 1996", "Mon DD, YYYY")),
    test.assertEqual(xs.date("1996-07-16"), core.parseDate("Jul 16,1996", "Mon DD, YYYY")),
    test.assertEqual(xs.date("1996-07-16"), core.parseDate("Jul 16, 1996", "Mon DD,YYYY")),
    test.assertEqual(xs.date("1996-07-16"), core.parseDate("Jul 16,1996", "Mon DD,YYYY")),

    test.assertEqual(null, core.parseDate("07.16.1996", "Mon DD,YYYY")),
    test.assertEqual(null, core.parseDate("notADate", "Mon DD,YYYY"))
  ];
}

function testInvalidDateFormat() {
  let error = null;
  try {
    core.parseDate("01-01-2019", "Mon YYYY DD");
  } catch (e) {
    error = e;
  }

  return [<commit_msg>DHFPROD-3620: extra comma removal<commit_after>const core = require('/data-hub/5/mapping-functions/core.sjs');
const test = require("/test/test-helper.xqy");

function testParseDate() {
  return [
    test.assertTrue(xs.date("2014-01-06").eq(core.parseDate("01/06/2014", "MM/DD/YYYY"))),
    test.assertTrue(xs.date("2014-01-06").eq(core.parseDate("06/01/2014","DD/MM/YYYY"))),
    test.assertTrue(xs.date("2014-01-06").eq(core.parseDate("01.06.2014","MM.DD.YYYY"))),
    test.assertTrue(xs.date("2014-01-06").eq(core.parseDate("06.01.2014", "DD.MM.YYYY"))),
    test.assertTrue(xs.date("2014-01-06").eq(core.parseDate("20140106", "YYYYMMDD"))),
    test.assertTrue(xs.date("2014-01-06").eq(core.parseDate("Jan 06, 2014", "Mon DD, YYYY")))
  ];
}

function testMoreParseDate() {
  return [
    test.assertEqual(xs.date("2018-01-02"), core.parseDate("01-02-2018", "MM-DD-YYYY")),
    test.assertEqual(xs.date("1996-07-16"), core.parseDate("Jul 16, 1996", "Mon DD, YYYY")),
    test.assertEqual(xs.date("1996-07-16"), core.parseDate("Jul 16,1996", "Mon DD, YYYY")),
    test.assertEqual(xs.date("1996-07-16"), core.parseDate("Jul 16, 1996", "Mon DD,YYYY")),
    test.assertEqual(xs.date("1996-07-16"), core.parseDate("Jul 16,1996", "Mon DD,YYYY")),

    test.assertEqual(null, core.parseDate("07.16.1996", "Mon DD,YYYY")),
    test.assertEqual(null, core.parseDate("notADate", "Mon DD,YYYY"))
  ];
}

function testInvalidDateFormat() {
  let error = null;
  try {
    core.parseDate("01-01-2019", "Mon YYYY DD");
  } catch (e) {
    error = e;
  }

  return [
{'fraction_non_alphanumeric': 0.23022279625443978, 'fraction_numerical': 0.11947045527930256, 'mean_word_length': 4.522281639928699, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5836904', 'n_tokens_mistral': 1465, 'n_tokens_neox': 1196, 'n_words': 155}