parseDate(dateString, options) {
    const localeData = this.loadedLocales.get(options?.locale || this.locale.name);
    let sourceFormat = options?.dateFormat || localeData.calendars[0]?.dateFormat.datetime;
    sourceFormat = sourceFormat.replace('. ', '.').replace('. ', '.');
    dateString = dateString.replace('. ', '.').replace('. ', '.');

    // ISO Date String
    if (dateString.indexOf('T') > -1 && dateString.substr(dateString.length - 1) === 'Z') {
      return new Date(dateString);
    }

    // Validation
    if (/^0*$/.test(dateString)) {
      return undefined;
    }

    // Remove AM/PM
    const separator = this.#determineSeparator(sourceFormat);
    const dayPeriods = localeData.calendars[0].dayPeriods;
    const is12Hr = dateString.indexOf(dayPeriods[0]) > -1 || dateString.indexOf(dayPeriods[1]) > -1;
    const isAM = dateString.indexOf(dayPeriods[0]) > -1;
    if (is12Hr) {
      dateString = dateString.replace(`${dayPeriods[0]} `, '');
      dateString = dateString.replace(`${dayPeriods[1]} `, '');
      dateString = dateString.replace(`${dayPeriods[0]}`, '');
      dateString = dateString.replace(`${dayPeriods[1]}`, '');
    }

    // Parse the date
    const dateComponents = dateString.split(' ');
    const datePieces = dateComponents[0].split(separator);

    // Parse the time part
    let timePieces = dateComponents[1] ? dateComponents[1].split(':') : [0, 0, 0, 0];
    if (dateComponents[1] && dateComponents[1].indexOf('.') > -1) {
      timePieces = dateComponents[1].split('.');
    }
    const formatComponents = sourceFormat.split(' ');
    const formatPieces = formatComponents[0].split(separator);

    const month = this.#determineDatePart(formatPieces, datePieces, 'M', 'MM', 'MMM', 'MMMM');
    const year = this.#determineDatePart(formatPieces, datePieces, 'y', 'yy', 'yyyy');
    const day = this.#determineDatePart(formatPieces, datePieces, 'd', 'dd', 'dddd');

    // Adjust for AM / PM
    if (is12Hr && !isAM && Number(timePieces[0]) !== 12) {
      timePieces[0] = Number(timePieces[0]) + 12;
    }
    if (is12Hr && isAM && Number(timePieces[0]) === 12) {
      timePieces[0] = 0;
    }
    if (is12Hr && !isAM && Number(timePieces[0]) === 12) {
      timePieces[0] = 12;
    }

    // Return arrays for arabic dates
    if (this.isIslamic()) {
      return [
        Number(this.twoToFourDigitYear(year)),
        (month - 1),
        Number(day),
        Number(timePieces && timePieces[0] ? timePieces[0] : 0),
        Number(timePieces && timePieces[1] ? timePieces[1] : 0),
        Number(timePieces && timePieces[2] ? timePieces[2] : 0)
      ];
    }

    return (new Date(
      this.twoToFourDigitYear(year),
      (month - 1),
      day,
      (timePieces && timePieces[0] ? timePieces[0] : 0),
      (timePieces && timePieces[1] ? timePieces[1] : 0),
      (timePieces && timePieces[2] ? timePieces[2] : 0),
    ));
  }
/**
   * Takes a formatted date string and parses back it into a date object
   * @param {string} dateString  The string to parse in the current format
   * @param {string|object} options  Additional options like locale and dateFormat
   * @returns {Date | Array | undefined} The date object it could calculate from the string
   */
Takes a formatted date string and parses back it into a date object
@param {string} dateString  The string to parse in the current format
@param {string|object} options  Additional options like locale and dateFormat
@returns {Date | Array | undefined} The date object it could calculate from the string
Takes a formatted date string and parses back it into a date object @param { string } dateString The string to parse in the current format @param { string|object } options Additional options like locale and dateFormat @returns { Date | Array | undefined } The date object it could calculate from the string
parseDate(dateString, options) {
    const localeData = this.loadedLocales.get(options?.locale || this.locale.name);
    let sourceFormat = options?.dateFormat || localeData.calendars[0]?.dateFormat.datetime;
    sourceFormat = sourceFormat.replace('. ', '.').replace('. ', '.');
    dateString = dateString.replace('. ', '.').replace('. ', '.');
    if (dateString.indexOf('T') > -1 && dateString.substr(dateString.length - 1) === 'Z') {
      return new Date(dateString);
    }
    if (/^0*$/.test(dateString)) {
      return undefined;
    }
    const separator = this.#determineSeparator(sourceFormat);
    const dayPeriods = localeData.calendars[0].dayPeriods;
    const is12Hr = dateString.indexOf(dayPeriods[0]) > -1 || dateString.indexOf(dayPeriods[1]) > -1;
    const isAM = dateString.indexOf(dayPeriods[0]) > -1;
    if (is12Hr) {
      dateString = dateString.replace(`${dayPeriods[0]} `, '');
      dateString = dateString.replace(`${dayPeriods[1]} `, '');
      dateString = dateString.replace(`${dayPeriods[0]}`, '');
      dateString = dateString.replace(`${dayPeriods[1]}`, '');
    }
    const dateComponents = dateString.split(' ');
    const datePieces = dateComponents[0].split(separator);
    let timePieces = dateComponents[1] ? dateComponents[1].split(':') : [0, 0, 0, 0];
    if (dateComponents[1] && dateComponents[1].indexOf('.') > -1) {
      timePieces = dateComponents[1].split('.');
    }
    const formatComponents = sourceFormat.split(' ');
    const formatPieces = formatComponents[0].split(separator);
    const month = this.#determineDatePart(formatPieces, datePieces, 'M', 'MM', 'MMM', 'MMMM');
    const year = this.#determineDatePart(formatPieces, datePieces, 'y', 'yy', 'yyyy');
    const day = this.#determineDatePart(formatPieces, datePieces, 'd', 'dd', 'dddd');
    if (is12Hr && !isAM && Number(timePieces[0]) !== 12) {
      timePieces[0] = Number(timePieces[0]) + 12;
    }
    if (is12Hr && isAM && Number(timePieces[0]) === 12) {
      timePieces[0] = 0;
    }
    if (is12Hr && !isAM && Number(timePieces[0]) === 12) {
      timePieces[0] = 12;
    }
    if (this.isIslamic()) {
      return [
        Number(this.twoToFourDigitYear(year)),
        (month - 1),
        Number(day),
        Number(timePieces && timePieces[0] ? timePieces[0] : 0),
        Number(timePieces && timePieces[1] ? timePieces[1] : 0),
        Number(timePieces && timePieces[2] ? timePieces[2] : 0)
      ];
    }
    return (new Date(
      this.twoToFourDigitYear(year),
      (month - 1),
      day,
      (timePieces && timePieces[0] ? timePieces[0] : 0),
      (timePieces && timePieces[1] ? timePieces[1] : 0),
      (timePieces && timePieces[2] ? timePieces[2] : 0),
    ));
  }
parseDate ( dateString , options ) { const localeData = this . loadedLocales . get ( options ?. locale || this . locale . name ) ; let sourceFormat = options ?. dateFormat || localeData . calendars [ 0 ] ?. dateFormat . datetime ; sourceFormat = sourceFormat . replace ( '. ' , '.' ) . replace ( '. ' , '.' ) ; dateString = dateString . replace ( '. ' , '.' ) . replace ( '. ' , '.' ) ; if ( dateString . indexOf ( 'T' ) > - 1 && dateString . substr ( dateString . length - 1 ) === 'Z' ) { return new Date ( dateString ) ; } if ( / ^0*$ / . test ( dateString ) ) { return undefined ; } const separator = this . #determineSeparator ( sourceFormat ) ; const dayPeriods = localeData . calendars [ 0 ] . dayPeriods ; const is12Hr = dateString . indexOf ( dayPeriods [ 0 ] ) > - 1 || dateString . indexOf ( dayPeriods [ 1 ] ) > - 1 ; const isAM = dateString . indexOf ( dayPeriods [ 0 ] ) > - 1 ; if ( is12Hr ) { dateString = dateString . replace ( ` ${ dayPeriods [ 0 ] } ` , '' ) ; dateString = dateString . replace ( ` ${ dayPeriods [ 1 ] } ` , '' ) ; dateString = dateString . replace ( ` ${ dayPeriods [ 0 ] } ` , '' ) ; dateString = dateString . replace ( ` ${ dayPeriods [ 1 ] } ` , '' ) ; } const dateComponents = dateString . split ( ' ' ) ; const datePieces = dateComponents [ 0 ] . split ( separator ) ; let timePieces = dateComponents [ 1 ] ? dateComponents [ 1 ] . split ( ':' ) : [ 0 , 0 , 0 , 0 ] ; if ( dateComponents [ 1 ] && dateComponents [ 1 ] . indexOf ( '.' ) > - 1 ) { timePieces = dateComponents [ 1 ] . split ( '.' ) ; } const formatComponents = sourceFormat . split ( ' ' ) ; const formatPieces = formatComponents [ 0 ] . split ( separator ) ; const month = this . #determineDatePart ( formatPieces , datePieces , 'M' , 'MM' , 'MMM' , 'MMMM' ) ; const year = this . #determineDatePart ( formatPieces , datePieces , 'y' , 'yy' , 'yyyy' ) ; const day = this . #determineDatePart ( formatPieces , datePieces , 'd' , 'dd' , 'dddd' ) ; if ( is12Hr && ! isAM && Number ( timePieces [ 0 ] ) !== 12 ) { timePieces [ 0 ] = Number ( timePieces [ 0 ] ) + 12 ; } if ( is12Hr && isAM && Number ( timePieces [ 0 ] ) === 12 ) { timePieces [ 0 ] = 0 ; } if ( is12Hr && ! isAM && Number ( timePieces [ 0 ] ) === 12 ) { timePieces [ 0 ] = 12 ; } if ( this . isIslamic ( ) ) { return [ Number ( this . twoToFourDigitYear ( year ) ) , ( month - 1 ) , Number ( day ) , Number ( timePieces && timePieces [ 0 ] ? timePieces [ 0 ] : 0 ) , Number ( timePieces && timePieces [ 1 ] ? timePieces [ 1 ] : 0 ) , Number ( timePieces && timePieces [ 2 ] ? timePieces [ 2 ] : 0 ) ] ; } return ( new Date ( this . twoToFourDigitYear ( year ) , ( month - 1 ) , day , ( timePieces && timePieces [ 0 ] ? timePieces [ 0 ] : 0 ) , ( timePieces && timePieces [ 1 ] ? timePieces [ 1 ] : 0 ) , ( timePieces && timePieces [ 2 ] ? timePieces [ 2 ] : 0 ) , ) ) ; }
Takes a formatted date string and parses back it into a date object
 @param {string} dateString  The string to parse in the current format
 @param {string|object} options  Additional options like locale and dateFormat
 @returns {Date | Array | undefined} The date object it could calculate from the string
Takes a formatted date string and parses back it into a date object @param { string } dateString The string to parse in the current format @param { string|object } options Additional options like locale and dateFormat @returns { Date | Array | undefined } The date object it could calculate from the string
// ISO Date String // Validation // Remove AM/PM // Parse the date // Parse the time part // Adjust for AM / PM // Return arrays for arabic dates