Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private getIntValueCJK(value: string): number {
let resultStr = value;
let isDozen = false;
let isPair = false;
if (RegExpUtility.isMatch(this.config.dozenRegex, resultStr)) {
isDozen = true;
if (this.config.cultureInfo.code.toLowerCase() === Culture.Chinese) {
resultStr = resultStr.substr(0, resultStr.length - 1);
}
else if (this.config.cultureInfo.code.toLowerCase() === Culture.Japanese) {
resultStr = resultStr.substr(0, resultStr.length - 3);
}
}
else if (RegExpUtility.isMatch(this.config.pairRegex, resultStr)) {
isPair = true;
resultStr = resultStr.substr(0, resultStr.length - 1);
}
resultStr = this.replaceUnit(resultStr);
let intValue = 0;
let partValue = 0;
}
for (j; j < ersTime.length; j++) {
timeResults.push(ersTime[j]);
}
timeResults = timeResults.sort((a, b) => a.start > b.start ? 1 : a.start < b.start ? -1 : 0);
let idx = 0;
while (idx < timeResults.length - 1) {
let current = timeResults[idx];
let next = timeResults[idx + 1];
if (current.type === Constants.SYS_DATETIME_DATE && next.type === Constants.SYS_DATETIME_TIMEPERIOD) {
let middleBegin = current.start + current.length;
let middleEnd = next.start;
let middleStr = source.substring(middleBegin, middleEnd).trim();
if (StringUtility.isNullOrWhitespace(middleStr) || RegExpUtility.isMatch(this.config.prepositionRegex, middleStr)) {
let periodBegin = current.start;
let periodEnd = next.start + next.length;
tokens.push(new Token(periodBegin, periodEnd));
}
idx++;
}
idx++;
}
return tokens;
}
private getDigitValueCJK(value: string, power: number): number {
let isNegative = false;
let resultStr = value;
if (RegExpUtility.isMatch(this.config.negativeNumberSignRegex, resultStr)) {
isNegative = true;
resultStr = resultStr.substr(1);
}
resultStr = this.replaceFullWithHalf(resultStr);
let result = this.getDigitalValue(resultStr, power);
if (isNegative) {
result = - result;
}
return result;
}
isWeekOnly(source: string): boolean {
let trimedText = source.trim().toLowerCase();
return (FrenchDateTime.WeekTerms.some(o => trimedText.endsWith(o)) ||
(FrenchDateTime.WeekTerms.some(o => trimedText.includes(o)) &&
(RegExpUtility.isMatch(this.nextSuffixRegex, trimedText) ||
RegExpUtility.isMatch(this.pastSuffixRegex, trimedText)))) &&
!FrenchDateTime.WeekendTerms.some(o => trimedText.endsWith(o));
}
private isLunar(source: string): boolean {
return RegExpUtility.isMatch(this.lunarHolidayRegex, source);
}
month = Constants.MinMonth;
year++;
}
}
else if (RegExpUtility.isMatch(this.tokenLastRegex, monthStr)) {
month--;
if (month === Constants.MinMonth - 1) {
month = Constants.MaxMonth;
year--;
}
}
if (hasYear) {
if (RegExpUtility.isMatch(this.tokenNextRegex, yearStr)) {
year++;
}
else if (RegExpUtility.isMatch(this.tokenLastRegex, yearStr)) {
year--;
}
}
}
result.timex = DateTimeFormatUtil.luisDate(hasYear ? year : -1, hasMonth ? month : -1, day);
let futureDate: Date;
let pastDate: Date;
if (day > this.getMonthMaxDay(year, month)) {
let futureMonth = month + 1;
let pastMonth = month - 1;
let futureYear = year;
let pastYear = year;
if (futureMonth === Constants.MaxMonth + 1) {
let monthStr = match.groups('thismonth').value;
let dayStr = match.groups('day').value;
day = this.config.dayOfMonth.get(dayStr);
let hasYear = !StringUtility.isNullOrEmpty(yearStr);
let hasMonth = !StringUtility.isNullOrEmpty(monthStr);
if (hasMonth) {
if (RegExpUtility.isMatch(this.tokenNextRegex, monthStr)) {
month++;
if (month === Constants.MaxMonth + 1) {
month = Constants.MinMonth;
year++;
}
}
else if (RegExpUtility.isMatch(this.tokenLastRegex, monthStr)) {
month--;
if (month === Constants.MinMonth - 1) {
month = Constants.MaxMonth;
year--;
}
}
if (hasYear) {
if (RegExpUtility.isMatch(this.tokenNextRegex, yearStr)) {
year++;
}
else if (RegExpUtility.isMatch(this.tokenLastRegex, yearStr)) {
year--;
}
}
}
isFuture(source: string): boolean {
return (RegExpUtility.isMatch(this.thisPrefixRegex, source)
|| RegExpUtility.isMatch(this.nextPrefixRegex, source));
}