Convert 1 - 7 from Day Number to Day Name

Hi, I adapted the answer from Convert 1-12 into month number for days of the week.

{
  "Name": "DayName",
  "CreationDate": "2022-02-22",
  "Commands": [
    {
      "Command": "store",
      "Target": "7",
      "Value": "d",
      "Description": ""
    },
    {
      "Command": "executeScript_Sandbox",
      "Target": "var days = [ \"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\" ]; var selectedDayName = days[${d} -1]; return selectedDayName;",
      "Value": "d2",
      "Description": "We use d-1 because arrays start at 0.  7 minus 1 equals 6, or six days from the current day"
    },
    {
      "Command": "echo",
      "Target": "The day is ${d2}",
      "Value": "green",
      "Description": ""
    }
  ]
}

Nice code snippet, thanks.

In emails and appointments, the using a day and a date, for example, “Monday, 02/28/2022” instead of only “02/28/2022” is more friendly-sounding, I think.

I agree that adding “Monday” to an email is more friendly-sounding. How do you get the day of the week from the date?

I finally discovered how to create a future date from the current date. Just change the “+1” to another number, as wanted.

“Command: executeScript_Sandbox
Target:
const current = new Date();
const options = { weekday: ‘long’, year: ‘numeric’, month: ‘long’, day: ‘numeric’ };
current.setDate(current.getDate()+1);
return(current.toLocaleDateString(undefined, options));
Value: wd”

( “From: Date.prototype.toLocaleDateString() - JavaScript | MDN” )
It returns the full name of the weekday, Month, Date, Year.
(For example: Sunday, March 13, 2022)

{
“Name”: “Date to Day of Week”,
“CreationDate”: “2022-4-14”,
“Commands”: [
{
“Command”: “executeScript_Sandbox”,
“Target”: “const current = new Date();\nconst options = { weekday: ‘long’, year: ‘numeric’, month: ‘long’, day: ‘numeric’ };\ncurrent.setDate(current.getDate()+1);\nreturn(current.toLocaleDateString(undefined, options));”,
“Value”: “wd”,
“Description”: “”
},
{
“Command”: “echo”,
“Target”: “check the day: ${wd}”,
“Value”: “aqua”,
“Description”: “”
}
]
}