Page 1 of 1

[REACT] Is there a way to comapre recurrent dates

Posted: Wed Nov 30, 2022 3:03 pm
by bhavisure

Hi,
We want to compare the start and enddate of the task with the resource's recurrentstart date and recurrentend date.

For example:
say a resource's calendar is

[
        {
          id: -2147463581,
          intervals: [
            {
              isWorking: false,
              name: "DayOff",
              recurrentEndDate: "at 06:00",
              recurrentStartDate: "at 10:00",
              type: "DayOff",
            },
          ],
        },
      ]

that is he does not work from 10 am to next day 6 am

And there is a task whose start time is say today 4 pm to tomorrow 1 am(night).

Now how can I compare whether the task time false between the recurrentstartdate and recurrentenddate of the resource ?

as you can see the task false inside the recurrentstartdate and recurrentenddate of the resource . How can I find this?

I also tried using https://bryntum.com/products/gantt/docs/api/Core/helper/DateHelper#function-timeSpanContains-static
is not working since , I want to compare only time .

How to proceed ?


Re: [REACT] Is there a way to comapre recurrent dates

Posted: Thu Dec 01, 2022 5:20 am
by alex.l

Sounds like this is that you re looking for https://bryntum.com/products/gantt/docs/api/SchedulerPro/model/CalendarModel#function-isWorkingTime

Checks if there is a working time interval in the provided time range


Re: [REACT] Is there a way to comapre recurrent dates

Posted: Thu Dec 01, 2022 7:44 am
by bhavisure

Hi Alex ,
tried using isworking

[
        {
          id: -2147463581,
          intervals: [
            {
             
isWorking: "false", name: "DayOff", recurrentEndDate: "at 06:00", recurrentStartDate: "at 10:00", }, { isWorking: "false", name: "DayOff", recurrentEndDate: "at 09:00", recurrentStartDate: "at 17:00", }, ], }, ]

this is the interval I gave

The start and date are
start date : Tue Nov 15 2022 03:15:55 GMT+0530 (India Standard Time)
enddate: Tue Nov 15 2022 04:15:55 GMT+0530 (India Standard Time)

When I tried giving this time and date its throwing "False"

record.effectiveCalendar.isWorkingTime(taskStore.getById(assignment.eventId).startDate,taskStore.getById(assignment.eventId).endDate)

but still the timing falls in the working hours .
Why is the response false ?


Re: [REACT] Is there a way to comapre recurrent dates

Posted: Thu Dec 01, 2022 7:54 am
by alex.l

What is record.effectiveCalendar? Does record have own calendar, is it resource with calendar assigned or task record that uses project's default calendar?

Check the id of record.effectiveCalendar to see if it's correct calendar.


Re: [REACT] Is there a way to comapre recurrent dates

Posted: Thu Dec 01, 2022 8:16 am
by bhavisure

It is resource with calendar assigned and also checked the id it is same id as it is assigned to the resource

[
        {
          id: -2147455388,
          calendar: -2147463581,
          name: "00000910",
        },
      ]

this is the resource data , the "calendar" field id is same as that of the calendar store id


Re: [REACT] Is there a way to comapre recurrent dates

Posted: Thu Dec 01, 2022 2:51 pm
by alex.l

Could you please attach all data to check that? JSON with all data required - complete load JSON.

I tried to change our advanced example and used your calendar in our launch-sass.json

 "calendars"    : {
        "rows" : [
            {
                "id"        : "user",
                "name"      : "User",
                "intervals" : [
                    {

                    "isWorking": "false",
                    "name": "DayOff",
                    "recurrentEndDate": "at 06:00",
                    "recurrentStartDate": "at 10:00"
                  },
                  {

                    "isWorking": "false",
                    "name": "DayOff",
                    "recurrentEndDate": "at 09:00",
                    "recurrentStartDate": "at 17:00"
                  }
            ]
        },

Also applied that to one of resources

    "resources"    : {
        "rows" : [
            {
                "id"       : 1,
                "name"     : "Celia",
                "city"     : "Barcelona",
                "calendar" : "user",
                "image"    : "celia.jpg"
            },

After that in console I got that resource and tried

 
start = new Date(2022, 10, 15, 3, 15, 55)
end = new Date(2022, 10, 15, 4, 15, 55)
gantt.resourceStore.getAt(0).effectiveCalendar.isWorkingTime(start, end)

it returns true