Using unprint for Perv City . Updated unprint for date formats.
This commit is contained in:
@@ -59,11 +59,23 @@ function kgToLbs(kgs) {
|
||||
return Math.round(Number(kilos) / 0.453592);
|
||||
}
|
||||
|
||||
function curateConvertInput(string) {
|
||||
if (/['’]|(fe*t)/.test(string)) {
|
||||
const result = string.match(/(\d+).*(\d+)/);
|
||||
|
||||
if (result) {
|
||||
return `${result[1]}ft ${result[2]}in`;
|
||||
}
|
||||
}
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
function convertManyApi(input, to) {
|
||||
const curatedInput = input
|
||||
.replace(/['’]\s*/, 'ft ') // ensure 1 space
|
||||
.replace(/["”]|('')/, 'in') // 5’4”
|
||||
.replace(/\d+ft\s*\d+\s*$/, (match) => `${match}in`); // height without any inch symbol
|
||||
const curatedInput = curateConvertInput(input);
|
||||
|
||||
console.log('CONVERT', input);
|
||||
console.log('RESULT', curatedInput);
|
||||
|
||||
return Math.round(convertMany(curatedInput).to(to)) || null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user