/*
Provides a date modify function

Expected params:
value   string|date anything that can be passed to newLocalDate()
modify  string      the modification to make, e.g. +1 week, tomorrow, etc.
format  string      date format to return
767080
public function modify()
    {
        $date   = $this->getParameter('value');
        $modify = (string) $this->getParameter('modify');
        $format = (string) $this->getParameter('format');

        if (empty($date))
            $date = 'now';

        if ($date instanceof Meta)
            $date = $date->MetaValue;

        if (!$date instanceof Date) {
            try {
                $date = $this->DateFactory->newLocalDate($date);
            } catch(DateException $e) {
                $date = $this->DateFactory->newLocalDate('now');
            }
        }

        $date = $this->DateFactory->toLocalDate($date);
        if (!empty($modify)) {
            try {
                $date->modify($modify);
            } catch (Exception $e) {
                return '';
            }
        }

        return $date->format($format);
    }
74764
function(dateString) {
        var match = dateString.match(DATE_REGEXP);

        var year = this._validateYear(+match[1]);

        var month = +match[2];
        var isIntercalary = !!match[3];
        var monthIndex = this.toMonthIndex(year, month, isIntercalary);

        var day = +match[4];

        return this.newDate(year, monthIndex, day);
    }
496529
function (date, options) {
        var q = $q.defer();

        navigator.globalization.dateToString(
          date,
          function (result) {
            q.resolve(result);
          },
          function (err) {
            q.reject(err);
          },
          options);
        return q.promise;
      }
581729
function formatDate(lang, input) {

	var result = input;
	var matches;
	var localeDateString;

	while ((matches = DATE_REGEX.exec(input)) != null) {

		var date = new Date(Date.parse(matches[1]));
		var format = matches[2] != undefined ? matches[2].toLowerCase() : "compact";

		if (format != "compact") {
			localeDateString = date.toLocaleDateString(lang,
				{
					day: "numeric",
					weekday: format,
					month: format,
					year: "numeric"
				});
		}
		else {
			localeDateString = date.toLocaleDateString();
		}
		result = result.replace(matches[0], localeDateString);
	};
	return result;

}
695344
function formatDate(date, format)
  {
    let parsedDate = new Date(date)
    if (!isDate(parsedDate))
      throw new TypeError("A date or timestamp must be provided to {{formatDate}}")

    if (isString(format) && format in formats.date)
      format = formats.date[format]

    return getCachedDateTimeFormat(locale, format).format(parsedDate)
  }
1356143
function toLocalIsoString(date, includeMillis) {
    if (includeMillis === undefined) {
        includeMillis = false;
    }
    const pad = (n, length, padChar) => {
        if (length === undefined) { length = 2; }
        if (padChar === undefined) { padChar = "0"; }
        let str = "" + n;
        while (str.length < length) {
            str = padChar + str;
        }
        return str;
    };
    const getOffsetFromUTC = () => {
        const offset = date.getTimezoneOffset();
        if (offset === 0) {
            return "Z";
        }
        return (offset < 0 ? "+" : "-")
            + pad(Math.abs(offset / 60), 2) + ":"
            + pad(Math.abs(offset % 60), 2);
    };
    return date.getFullYear() + "-"
        + pad(date.getMonth() + 1) + "-"
        + pad(date.getDate()) + "T"
        + pad(date.getHours()) + ":"
        + pad(date.getMinutes()) + ":"
        + pad(date.getSeconds())
        + (includeMillis ? "." + pad(date.getMilliseconds(), 3) : "")
        + getOffsetFromUTC();
}
569135
function(val, sendUpdatedEvt) {
	
	   // Don't try to parse a date if there is no date
	   if( val === '' ) {
	      inputEx.DateField.superclass.setValue.call(this, '', sendUpdatedEvt);
	      return;
	   }
	   var str = "";
	   if (val instanceof Date) {
			str = inputEx.DateField.formatDate(val, this.options.dateFormat);
	   } 
		else if(this.options.valueFormat){
			var dateVal = inputEx.DateField.parseWithFormat(val, this.options.valueFormat);
			str = inputEx.DateField.formatDate(dateVal, this.options.dateFormat);
		}
	   // else date must match this.options.dateFormat
	   else {
	     str = val;
	   }
	
	   inputEx.DateField.superclass.setValue.call(this, str, sendUpdatedEvt);
	}
1225243
@Nullable
    public static MultiDayOfTheWeek valueOf(@Nullable final String str) {
        if (str == null) {
            return null;
        }
        return new MultiDayOfTheWeek(str);
    }
792092
function formatDate( date ) {

	var dateString = '';

	date = new Date( date );

	dateString = date.getMonth() + 1;
	dateString += '/';
	dateString += date.getDate();
	dateString += '/';
	dateString += date.getFullYear();

	return dateString;
}
166489
public static java.util.Date parseDate(String dateString, String dateFormat) {
        java.util.Date newDate = null;

        try {
            newDate = new SimpleDateFormat(dateFormat, Locale.ENGLISH)
                    .parse(dateString);
        } catch (ParseException e) {
            QuickUtils.log.d("parse error", e);
        }
        return newDate;
    }
842329
function formatWeekDataAsModule(weekData) {
  const date = new Date();
  const { firstDay, weekendEnd, weekendStart } = weekData;
  const transformed = {
    firstDay: transformWeekDays(firstDay),
    weekendEnd: transformWeekDays(weekendEnd),
    weekendStart: transformWeekDays(weekendStart)
  };
  const formatted = JSON.stringify(transformed, null, 2);
  const js =
`// Generated at ${date}
// from https://github.com/unicode-cldr/cldr-core/blob/master/supplemental/weekData.json
const weekData = ${formatted};
export default weekData;
`;
  return js;
}
421052
function fixInvalidDate(dateString) {
  if (!dateString) {
    return;
  }

  //Convert invalid dates' timezones to GMT using timezoneMap
  dateString = dateString.replace(/BST?/i, function (match) {
    return timezoneMap[match];
  });

  //Some dates come in as ET, CT etc.. and some don't have the correct offset.
  //Matches /ET/EDT/EST/CT/CDT/CST/MT/MDT/MST/PT/PDT/PST if found at the end of a date string
  var newDateString = dateString.replace(/(E|C|M|P)[DS+]?T$/i, function (match) {
    var firstChar = match.charAt(0);
    return isDaylightSavingsTime() ? (firstChar + 'DT') : (firstChar + 'ST');
  });

  return new Date(newDateString);
}
1364930
function formatDate(date) {
            let settings = dateFormat || defaultAxisSettings;
            let format = null;
            let localeOptions = {month:'short', day:'numeric'};

            if (settings === axisTimeCombinations.DAY_MONTH || settings === axisTimeCombinations.MONTH_YEAR) {
                format = monthDayYearFormat;
                localeOptions.year = 'numeric';
            } else if (settings === axisTimeCombinations.HOUR_DAY || settings === axisTimeCombinations.MINUTE_HOUR) {
                format = monthDayHourFormat;
                localeOptions.hour = 'numeric';
            } else if (settings === axisTimeCombinations.CUSTOM && typeof dateCustomFormat === 'string') {
                format = d3TimeFormat.timeFormat(dateCustomFormat);
            }

            if (locale && ((typeof Intl !== 'undefined') && (typeof Intl === 'object' && Intl.DateTimeFormat))) {
                let f = Intl.DateTimeFormat(locale, localeOptions);

                return f.format(date);
            }

            return format(date);
        }
524734
function parseDate(date) {
  if (isDateObject(date)) { // 1
    return date;
  } else if (isValidTimeStamp(date)) { // 2
    return new Date(date);
  } else if (typeof date === 'string' && /^[0-9]{4}([-\.\/][0-9]{2}){2}$/.test(date)) { // 3
    date = date.split(/[-\.\/]/);

    return new Date(date[0], date[1] - 1, date[2]);
  }
  
  return; // ??
}
1306261
function(str, format) {
           var date = null, formattedBack;
           if(str) {
               date = this.dpg.parseDate(str, format, this.options.datetimepicker.language, this.options.formatType);
               if(typeof str === 'string') {
                   formattedBack = this.dpg.formatDate(date, format, this.options.datetimepicker.language, this.options.formatType);
                   if(str !== formattedBack) {
                       date = null;
                   } 
               }
           }
           return date;
       }
196409
function(str, format) {
           var date = null, formattedBack;
           if(str) {
               date = this.dpg.parseDate(str, format, this.options.datepicker.language);
               if(typeof str === 'string') {
                   formattedBack = this.dpg.formatDate(date, format, this.options.datepicker.language);
                   if(str !== formattedBack) {
                       date = null;
                   }
               }
           }
           return date;
       }
903496
function makeDateFromStringAndFormat(config) {

        config._a = [];
        config._pf.empty = true;

        // This array is used to make a Date, either with `new Date` or `Date.UTC`
        var lang = getLangDefinition(config._l),
            string = '' + config._i,
            i, parsedInput, tokens, token, skipped,
            stringLength = string.length,
            totalParsedInputLength = 0;

        tokens = expandFormat(config._f, lang).match(formattingTokens) || [];

        for (i = 0; i < tokens.length; i++) {
            token = tokens[i];
            parsedInput = (getParseRegexForToken(token, config).exec(string) || [])[0];
            if (parsedInput) {
                skipped = string.substr(0, string.indexOf(parsedInput));
                if (skipped.length > 0) {
                    config._pf.unusedInput.push(skipped);
                }
                string = string.slice(string.indexOf(parsedInput) + parsedInput.length);
                totalParsedInputLength += parsedInput.length;
            }
            // don't parse if it's not a known token
            if (formatTokenFunctions[token]) {
                if (parsedInput) {
                    config._pf.empty = false;
                }
                else {
                    config._pf.unusedTokens.push(token);
                }
                addTimeToArrayFromToken(token, parsedInput, config);
            }
            else if (config._strict && !parsedInput) {
                config._pf.unusedTokens.push(token);
            }
        }

        // add remaining unparsed input length to the string
        config._pf.charsLeftOver = stringLength - totalParsedInputLength;
        if (string.length > 0) {
            config._pf.unusedInput.push(string);
        }

        // handle am pm
        if (config._isPm && config._a[HOUR] < 12) {
            config._a[HOUR] += 12;
        }
        // if is 12 am, change hours to 0
        if (config._isPm === false && config._a[HOUR] === 12) {
            config._a[HOUR] = 0;
        }

        dateFromConfig(config);
        checkOverflow(config);
    }