How old is Lana Coc-Kroft

martinharder/age.js

// German versionconstparams = args.widgetParameter? args.widgetParameter.split (','): null;constdateString = params && params.length> 0? params [0] .trim (): null;constname = params && params.length === 2? params [1] .trim (): zero;functioncalculateDateValues ​​(dateString) {constdob = newDate (dateString);constnow = newDate (Date.now ());consttotalDays = daysBetween (dob, now);consttotalMonths = monthsDiff (dob, now);constyears = Math.floor (totalMonths / 12);constmonths = totalMonths-Math.floor (years) * 12;constdaysLeft = calculateRestDays (dob, years, months);return{totalDays: totalDays,totalWeeks: Math.floor (totalDays / 7),totalMonths: totalMonths,years: years,months: months,daysLeft: daysLeft,restWeeks: Math.floor (daysLeft / 7),restDays: daysLeft-Math.floor (daysLeft / 7) * 7}}functiontoDays (d) {d = d || 0;returnd / 24/60/60/1000;}functiontoUTC (d) {if (! d ||! d.getFullYear) {return0;}returnDate.UTC (d.getFullYear (), d.getMonth (), d.getDate ());}// Number of days between two dates (d1, d2: Date)functiondaysBetween (d1, d2) {returntoDays (toUTC (d2) -toUTC (d1));}functiondaysInMonth (m, y) {vary = y || newDate (Date.now ()). getFullYear ();returntoDays (Date.UTC (y, m + 1,1) -Date.UTC (y, m, 1));}functiondaysInYear (y) {vary = y || newDate (Date.now ()). getFullYear ();return (toDays (Date.UTC (y + 1,0,1) -Date.UTC (y, 0,1)));}functionyearsDiff (d1, d2) {returnd2.getFullYear () - d1.getFullYear ();}functionmonthsDiff (d1, d2) {letyears = yearsDiff (d1, d2);letmonths = (years * 12) + (d2.getMonth () - d1.getMonth ());if (d2.getDate () months--;}returnmonths;}functioncalculateRestDays (date, years, months) {constday = date.getDate ();constmonth = date.getMonth ();constyear = date.getFullYear ();constnewDate = newDate (Date.UTC (year + years, month + months, day));constnow = newDate (Date.now ())returndaysBetween (newDate, now)}functionpluralize (amount, word) {letresult = wordswitch (word) {case'year ':case 'month':case'Tag ':if (amount> 1) {result + = 'e';}break;case 'week':if (amount> 1) {result + = 'n';}break;}returnresult;}functiongetTextArray (values) {lettextY, textM, textW, textD = null;if (values.years <1) {if (values.totalMonths> 0) {textM = values.totalMonths + '' + pluralize (values.totalMonths, 'month');if (values.restWeeks> 0) {textW = values.restWeeks + '' + pluralize (values.restWeeks, 'week');}if (values.restDays> 0) {textD = values.restDays + '' + pluralize (values.restDays, 'Tag');}} elseif (values.totalWeeks> 0) {textW = values.totalWeeks + '' + pluralize (values.totalWeeks, 'week');if (values.restDays> 0) {textD = values.restDays + '' + pluralize (values.restDays, 'Tag');}} elseif (values.totalDays> 0) {textD = values.totalDays + '' + pluralize (values.totalDays, 'Tag');}} else {textY = values.years + '' + pluralize (values.years, 'year');if (values.months> 0) {textM = values.months + '' + pluralize (values.months, 'month');if (values.restWeeks> 0) {textW = values.restWeeks + '' + pluralize (values.restWeeks, 'week');}if (values.restDays> 0) {textD = values.restDays + '' + pluralize (values.restDays, 'Tag');}} elseif (values.restWeeks> 0) {textW = values.restWeeks + '' + pluralize (values.restWeeks, 'week');if (values.restDays> 0) {textD = values.restDays + '' + pluralize (values.restDays, 'Tag');}} elseif (values.restDays> 0) {textD = values.restDays + '' + pluralize (values.restDays, 'Tag');}}consttextArray = [];if (textY) {textArray.push (textY);}if (textM) {textArray.push (textM);}if (textW) {textArray.push (textW);}if (textD) {textArray.push (textD);}constfinalTextArray = [];switch (textArray.length) {case4:finalTextArray.push (textArray [0] + ',');finalTextArray.push (textArray [1] + ',');finalTextArray.push (textArray [2] + 'and');finalTextArray.push (textArray [3] + 'alt.');break;case3:finalTextArray.push (textArray [0] + ',');finalTextArray.push (textArray [1] +