Date, Get Day of Week String
Date, Get Day of Week String
Gets the string for the day of the week. The notation of the day is set in the config such as “Sun,Mon,Tue,Wed,Thu,Fri,Sat” or “Closed,Open,Open,Open,Open,Open,Closed”. The beginning is Sunday.
Configs
  • A: Set Day Format in Csv (eg “(S),(M),(T),(W),(T),(F),(S)” ) *#{EL}
  • B: Set Date/Datetime to be Determined (eg “2022-04-29” ) *#{EL}
  • C: Select STRING DATA that stores Name of Day (update) *
Script (click to open)
// GraalJS Script (engine type: 2)

//////// START "main()" /////////////////////////////////////////////////////////////////
main();
function main(){ 

const strDayFormat    = configs.get( "StrConfA" );        /// REQUIRED /////////////
  if( strDayFormat  === "" ){
    throw new Error( "\n AutomatedTask ConfigError:" +
                     " Config {A: Day Format} is empty \n" );
  }
const strTarget       = configs.get( "StrConfB" );        /// REQUIRED /////////////
  if( strTarget     === "" ){
    throw new Error( "\n AutomatedTask ConfigError:" +
                     " Config {B: Date or Datetime} is empty \n" );
  }
  let dateTarget      = parseDateAsMidnight( strTarget ); // the first of the date
  engine.log( " AutomatedTask ConfigLog:" +
              " DayOfWeek of " + strTarget + " (Sun=0,Mon=1): " + dateTarget.getDay() );
const strPocketOutput = configs.getObject( "SelectConfC" ); /// REQUIRED ///////////


//// == Data Retrieving / ワークフローデータの参照 ==
// (Nothing. Retrieved via Expression Language in Config Retrieving)


//// == Calculating / 演算 ==
let arrDayFormat = strDayFormat.split(",");
let numDayId = dateTarget.getDay();


//// == Data Updating / ワークフローデータへの代入 ==
engine.setData( strPocketOutput, arrDayFormat[ numDayId ] );


} //////// END "main()" /////////////////////////////////////////////////////////////////


function parseDateAsMidnight( str ) { // Transform date from String to Date
  if( str === "" ){
    throw new Error( "\n AutomatedTask ParseDateError:" +
                     " String is empty \n" );
  }
  var arrNumParts = str.match( /\d+/g );
  if( arrNumParts === null ){
    throw new Error( "\n AutomatedTask ParseDateError:" +
                     " No numeric characters in: " + str + "\n" );
  }
  if( arrNumParts.length < 3){
    throw new Error( "\n AutomatedTask ParseDateError:" +
                     " 3 Parts of numeric characters are needed in: " + str + "\n" );
  }
  return new Date( parseInt(arrNumParts[0], 10), 
                   parseInt(arrNumParts[1], 10) - 1, 
                   parseInt(arrNumParts[2], 10) ); // months are 0-based
  // Note: new Date("2014-11-10") // Mon Nov 10 2014 09:00:00 GMT+0900 (JST)
  // Note: new Date(2014, 10, 10) // Mon Nov 10 2014 00:00:00 GMT+0900 (JST)
}
/*

Notes:
- When the process reaches the automated task, the day of the week of the date data is automatically determined.
    - `YYYY-MM-DD` (date type format), `YYYY/MM/DD`, etc.
    - `YYYY-MM-DD hh:mm` (datetime data format) can also be determined.
- Set the day of the week string in CSV format.
    - `Sun,Mon,Tue,Wed,Thu,Fri,Sat`
    - `Closed,Open,Open,Open,Open,Open,Closed`
    - `Sun.,Mon.,Tue.,Wed.,Thu.,Fri.,Sat.`
    - `(S),(M),(T),(W),(T),(F),(S)`
    - `Sun,Moon,Ares,Hermes,Zeus,Aphrodite,Cronos`
    - `日,月,火,水,木,金,土`
    - `定休日,営業日,営業日,営業日,営業日,営業日,定休日`
    - `(日),(月),(火),(水),(木),(金),(土)`
- Commas cannot be included in the day of the week string.

Notes-ja:
- 案件が自動処理工程に到達した際、日付データの曜日が自動判定されます。
    - `YYYY-MM-DD` (日付型データの書式) や `YYYY/MM/DD` など
    - `YYYY-MM-DD hh:mm` (日時型データの書式) も判定できます。
- 曜日文字列は、CSV書式で設定します。
    - `日,月,火,水,木,金,土`
    - `定休日,営業日,営業日,営業日,営業日,営業日,定休日`
    - `(日),(月),(火),(水),(木),(金),(土)`
    - `Sun,Mon,Tue,Wed,Thu,Fri,Sat`
    - `Closed,Open,Open,Open,Open,Open,Closed`
    - `Sun.,Mon.,Tue.,Wed.,Thu.,Fri.,Sat.`
    - `(S),(M),(T),(W),(T),(F),(S)`
    - `Sun,Moon,Ares,Hermes,Zeus,Aphrodite,Cronos`
- 曜日文字列にカンマは含められません。
*/

Download

2021-10-01 (C) Questetra, Inc. (MIT License)
https://support.questetra.com/addons/date-get-day-of-week-string-2021/
The Add-on import feature is available with Professional edition.
Freely modifiable JavaScript (ECMAScript) code. No warranty of any kind.

Notes

  • When the process reaches the automated task, the day of the week of the date data is automatically determined.
    • YYYY-MM-DD (date type format), YYYY/MM/DD, etc.
    • YYYY-MM-DD hh:mm (datetime data format) can also be determined.
  • Set the day of the week string in CSV format.
    • Sun,Mon,Tue,Wed,Thu,Fri,Sat
    • Closed,Open,Open,Open,Open,Open,Closed
    • Sun.,Mon.,Tue.,Wed.,Thu.,Fri.,Sat.
    • (S),(M),(T),(W),(T),(F),(S)
    • Sun,Moon,Ares,Hermes,Zeus,Aphrodite,Cronos
    • 日,月,火,水,木,金,土
    • 定休日,営業日,営業日,営業日,営業日,営業日,定休日
    • (日),(月),(火),(水),(木),(金),(土)
  • Commas cannot be included in the day of the week string.

Capture

Gets the string for the day of the week. The notation of the day is set in the config such as "Sun,Mon,Tue,Wed,Thu,Fri,Sat" or "Closed,Open,Open,Open,Open,Open,Closed". The beginning is Sunday.
Gets the string for the day of the week. The notation of the day is set in the config such as "Sun,Mon,Tue,Wed,Thu,Fri,Sat" or "Closed,Open,Open,Open,Open,Open,Closed". The beginning is Sunday.

See also

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: