機械翻訳について

雇用プロセスの例

このトピックでは、雇用プロセスのユース・ケースに使用できるjavascriptコードの例をいくつか示します。

アサイメント履歴のループ

function runCondition(context) {
 
    const { $componentContext, $fields, $modules, $user, $value } = context;
    const empWorkerAsgHistory = $fields["employmentWorkerAssignmentHistory"].$value();
    if(empWorkerAsgHistory){
 
      const empAsgHistory = $fields["employmentWorkerAssignmentHistory.employmentAssignmentsHistory"].$value();
      if(empAsgHistory) {
 
        for(const key in empAsgHistory) {
          if(empAsgHistory[key].ActionCode === "ASG_CHANGE"){
            return true;
          }
        }
      }
    }
 
    return false;
 
  }
  return { runCondition };
 
});

時期および事由の日付が月の1日または15日である場合

function isFirstOrFifteenth(date) {
  const day = date.getDate();
  if (day === 1 || day === 15) {
    return true; // The date is on the 1st or 15th
  }
  return false; // The date is not on the 1st or 15th
}
2つの日付オブジェクト間の年数の差を取得
//d1 and d2 are date objects and d2 > d1
function dateDiff(d1,d2) {
    let diff = (d2.getTime() - d1.getTime()) / 1000;
    diff /= (60 * 60 * 24);
   
    return (diff / 365.25);
  }

指定した日付から月を減算または加算

function subtractMonthsFromDate(inputDate, months) {
    const date = new Date(inputDate);
    date.setMonth(date.getMonth() - months);
    return date;
}

当年がうるう年かどうかをチェックする機能

//date is a Date object
function isLeapYear(date) {
  const year = date.getFullYear();
 
  if ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0) {
    return true;
  }
  return false; // The year is not a leap year
}