dateimacros

iMacros: How to get the DATE with EVAL


can someone to give me an direction on this, please

I need this with EVAL, because .js not supported by Chrome.

I have the {{!EXTRACT}} and EVAL {{Day1}} {{Day2}} {{Day3}} {{Day4}}.. {{Day10}}..{{Day20}}

I am extracting from the webpage DATE in this format Oct 10, 2022

if {{!EXTRACT}} value is from the past, let's say Oct 1, 2022 then {{Day1}} value will be the next day after local machine current date, in this case Oct 12, 2022 , then {{Day2}} Oct 13, 2022 , {{Day3}} Oct 14, 2022 and continue with how many days I SET to generate

Then

if case {{!EXTRACT}} value is from the future, Oct 23, 2022, then {{Day1}} value will be the next day Oct 24, 2022, then {{Day2}} Oct 25, 2022 , {{Day3}} Oct 26, 2022 and continue with how many days I SET

hope my information is clear really don't know how to approach this thank you again

I am using (FCI): iMacros for CR v10.1.1 'PE', CR v105.0.5195.102 (_x64), Win10_x64. ('CR' = 'Chrome' / 'PE' = 'Personal Edition')


Solution

  • Just trying to give value to the SO comunity as so many times someone with experience helped me.

    I found the solution

    SET !EXTRACT "Oct 21, 2022"
    SET Day1 EVAL("var add = 1; var result = new Date(); var resultText = ''; var extract = new Date('{{!EXTRACT}}').setHours(0,0,0,0); var today = new Date().setHours(0,0,0,0); if(today > extract){ result.setDate(new Date(today).getDate() + add); } else {result.setDate(new Date(extract).getDate() + add);} resultText = result.toLocaleString('en-US', {month: 'short'}) + ' ' + result.getDate() + ', ' + result.getFullYear(); resultText;")
    
    SET Day2 EVAL("var add = 2; var result = new Date(); var resultText = ''; var extract = new Date('{{!EXTRACT}}').setHours(0,0,0,0); var today = new Date().setHours(0,0,0,0); if(today > extract){ result.setDate(new Date(today).getDate() + add); } else {result.setDate(new Date(extract).getDate() + add);} resultText = result.toLocaleString('en-US', {month: 'short'}) + ' ' + result.getDate() + ', ' + result.getFullYear(); resultText;")
    
    PROMPT {{Day1}}_{{Day2}}_