Skip to content

Commit

Permalink
Fixed logic when time of day is specified
Browse files Browse the repository at this point in the history
  • Loading branch information
alordash committed Dec 8, 2020
1 parent f6c7823 commit 6551234
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
11 changes: 10 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
module.exports = require('./lib/date-parser');
module.exports = require('./lib/date-parser');
const { parseDate, extractRegexChars } = require('./lib/date-parser');
const original = 'а тут ты 20 минут утром русский написал и всн';
const res = parseDate(original, 1, 50);
const chars = extractRegexChars(original, 1);
let regexs = '';
chars.forEach(e => regexs += e.regex_char);
console.log('regexs :>> ', regexs);
console.log('res :>> ', res);
console.log('exiting . . . ');
6 changes: 4 additions & 2 deletions lib/date-cases.js
Original file line number Diff line number Diff line change
Expand Up @@ -985,10 +985,12 @@ const finalParseCases = [
parsedTime.number = processHour(parsedTime.number, this.expressions[match.index].value);
parsedTime.prevalence += prevalence;
proceed = false;
parsedTime.isFixed = true;
}
parsedTime.isFixed = true;
}
parsedTimes[parsedTimesIndexes[i]].indexes.push(...markIndexes.call(this, match.index, 1, true, true));
if (i >= 0) {
parsedTimes[parsedTimesIndexes[i]].indexes.push(...markIndexes.call(this, match.index, 1, true, true));
}
}
}
return parsedTimes;
Expand Down
15 changes: 15 additions & 0 deletions spec/RU.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,21 @@ const stringTests = [
}
}
]
},
{
in: 'а тут ты 20 минут утром русский написал и всн',
outs:[
{
max_date: {},
period_time: {},
string: 'а тут ты утром русский написал и всн',
target_date:{
isFixed: false,
isOffset: false,
minutes: 20
}
}
]
}
];

Expand Down

0 comments on commit 6551234

Please sign in to comment.