Skip to content

Commit

Permalink
GoodGrind#14 Code have been reformatted to cover every loggable cases
Browse files Browse the repository at this point in the history
  • Loading branch information
MilanCsore committed May 21, 2020
1 parent bf5630f commit 00a1dab
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/police-hu/police-hu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,19 @@ export function queueTimeToMinutes(queueTime: string): number {
Converts the police.hu queue time string representation to a number.
For example, calling this function with '0/2 óra' would result in 30 (minutes).
*/
if (numberOfDigitsInqueueTime === 0) {
loggerError.error(`The text of queue time '${queueTime}' is not parsable. It doesn't contain numeric values`);
if (isEmpty(queueTime)) {
return 0;
}

if (isEmpty(queueTime) || numberOfDigitsInqueueTime>=3) {
loggerError.error(`The text of queue time '${queueTime}' is not parsable. A standard '0' value will be returned. `);
if (numberOfDigitsInqueueTime >= MAX_NUMBER_OF_QUEUETIME_DIGITS) {
logger.error(`The text of queue time '${queueTime}' is not parsable. A standard '0' value will be returned. `);
return 0;
}

if (!numberOfDigitsInqueueTime) {
logger.error(`The text of queue time '${queueTime}' is not parsable. It doesn't contain numeric values`);
}

const HOUR_POSTFIX = 'óra';
// we want to remove any unnecessary whitespaces and the hour postfix notation.
// this leaves the rational or whole number representation, meaning 1/2 or 1...
Expand Down

0 comments on commit 00a1dab

Please sign in to comment.