Sorry. Here’s the complete code that used to work on the backend with no issues.
export function enterContest01_afterQuery ( item , context ) {
if ( item . chineseName === undefined ) {
item . fullName = item . firstName + " " + item . playerSurname
}
else
{
item . fullName2 = item . firstName + " " + item . playerSurname + " " + item . chineseName ;
}
item . age = ageFromDob ( item . birthday );
item . createDate1 = createdate ( item . _createdDate );
item . diffDays = daystoBday ( item . birthday )
item . bdayDate1 = createdate ( item . birthday );
item . playerRefText = item . playerRef ;
return item ;
}
function ageFromDob ( birthday ) {
const now = new Date ();
const days = now . getDate () - birthday . getDate ();
const months = - now . getMonth () + birthday . getMonth ();
let age = now . getFullYear () - birthday . getFullYear () - months / 12 ;
//if (months < 0 || (months === 0 && days < 0))
{
//age–;
}
return age . toFixed ( 1 );
}