0

I'm confusing everything so rephrasing entire question:

I have 2 arrays. The var personalEntries: Entrymodel[] = []; and specialDates : Specialdates[] = [];

I Break down personalEntries untill it shares a format with specialDates

This format being MM/DD or 1201,1202,1203,1204

I have a ban Period of specific holidays Which is 4 years.

I now need to see weather my broken down array personalInbet

 var personalInbet : any[] = [];
    personalEntries.forEach(az => {
      az.inbet.forEach(i => {
        var x = (i.month+"-"+i.day+"-"+i.year);
        personalInbet.push(x);
      });
    });

Shares dates with specialDates. This I can do

by using something like:

    const result = this.personalInbet.filter(d => !this.specialDates.includes(d));

The Issue I have:

Is checking weather the users holiday dates are within the 4 year Ban period.

Now the only way I can think to do this is something kinda like this: its just a logical example Im ignoring any and all langue out of it

var x =  if(personalInbetween has duplicates in specialDates){
  if(x.year > 4)//Just a logical example Id need to see that the users dates fall into the specialdates and then access those user dates to get the year and then see if the year is below or over the ban period which is 4
  {
    //NoGO
  }
  else{
    go
  }

The main problem here being that SpecialDates only has Months,Days

And the users bookings has Days/Months/Years

So to compare the two arrays they need to be similar in values, But when they are I no longer have access to the years So i can see if the years are > 4

Azure21
  • 11
  • 3
  • Can you please shrink down your problem to the very problem you have? Is it comparing two dates? – DonJuwe Feb 15 '21 at 09:59
  • I don't really understand the question but [moment](https://momentjs.com/) might be useful. You can either take the current date, format it to MMYY with `moment().format('MMDD')` and check if this value exists in the special dates array OR you can do it in the opposite way : take dates as MMDD from the input array and convert them to dates using `moment(dateAsMMDD, 'MMDD').toDate()`. Hope that helps – Arnaud Denoyelle Feb 15 '21 at 10:05
  • Sorry im explaining it terribly like I said my brain is racked, And @DonJuwe Its after I compared the dates how do I check the year, I can compare to see if the current range is within the special dates range but I have no idea how to see about the years, Id love to share a more direct problem but the issue is I have no idea how to get to a instance where it just the one small problem – Azure21 Feb 15 '21 at 10:18
  • To get the difference in days convert your structure into the `Date` object with `new Date()`. Then you can get the difference easily with `Math.floor((date2 - date1) / (1000*60*60*24))`. See here: https://stackoverflow.com/questions/7763327/how-to-calculate-date-difference-in-javascript – DonJuwe Feb 15 '21 at 10:55
  • @DonJuwe I rephrased the question i think its a bit more clear now – Azure21 Feb 15 '21 at 11:11

0 Answers0