Premium support for our pure JavaScript UI components


Post by MauriceLapre »

Hi,

I'm trying to setup resource calenders for complex recurring shifts. E.g. a 14 day shift should set a calendar's working hours to:

  • day 1: 8hrs

  • day 2: 8hrs

  • day 3: 8hrs

  • day 4: 8hrs

  • day 5: 0hrs

  • day 6: 0hrs

  • day 7: 8hrs

  • day 8: 8hrs

  • day 9: 8hrs

  • day 10: 8hrs

  • day 11: 8hrs

  • day 12: 0hrs

  • day 13: 0hrs

  • day 14: 0hrs

This will be recurring (every 14 days), starting on a specific date, e.g. Monday July 18th 2022. By setting recurring isWorking=true intervals like "on Monday at 08:00" for 14 days, the first week is overwritten. I can't figure out yet how to do this. Any help would be appreciated, thanks!


Post by marcio »

Hi Maurice,

Sorry for the late reply. Considering that day 1 is a Monday, you can setup your data like this:

{
    "success"     : true,
    "project"     : {
        "calendar" : "workhours"
    },
    "calendars"   : {
        "rows" : [
            {
                "id"                       : "workhours",
                "name"                     : "Working hours",
                "unspecifiedTimeIsWorking" : true,
                "intervals"                : [
                    {
                        "recurrentStartDate" : "on Thu every 1 week",
                        "recurrentEndDate"   : "on Sat every 1 week",
                        "isWorking"          : false,
                        "name"               : "non working time 1"
                    },
                    {
                        "recurrentStartDate" : "on Sat every 2 weeks",
                        "recurrentEndDate"   : "on Sun every 2 weeks",
                        "isWorking"          : false,
                        "name"               : "non working time 2"
                    }
                ]
            }
        ]
    },
}

You can check more info about the intervals at Later.js page https://bunkat.github.io/later/index.html

Attachments
Screen Shot 2022-07-22 at 5.56.37 PM.png
Screen Shot 2022-07-22 at 5.56.37 PM.png (37.27 KiB) Viewed 169 times

Best regards,
Márcio


Post by MauriceLapre »

Thanks for your reply, that's getting close to what I want. But I'd like the recurrence to be fully custom. Shifts can e.g. also be a 10 day recurring schedule. I'm reading the later.js doc about custom time periods, but how can I create that? E.g. custom period is 10 days. Then use this to implement a recurring schedule like: on the 1st day of custom period, 8hrs working (with recurring start and end date/time). And on the 2nd day of custom period, 8hrs working and so on...
Is something like that possible?


Post by alex.l »

Try to specify rules like

"recurrentStartDate" : "every 14 days at 6:00 after 2021-03-30T00:00:00 before 2021-04-15T00:00:00",
"recurrentEndDate" : "every 14 days at 22:00 after 2021-03-30T00:00:00 before 2021-04-15T00:00:00",

Just as example.

Full docs you can find in docs of later.js https://bunkat.github.io/later/parsers.html

All the best,
Alex


Post by MauriceLapre »

Tried that, unfortunately that took every new month into account.

After a lot of puzzling, what seems to be working:

at 08:00 on the 2nd day of the week every 2 weeks starting on the 1st week of the year

For the first 7 days of the 14 day period. And:

at 08:00 on the 3rd day of the week every 2 weeks starting on the 2nd week of the year

For the second 7 days of the 14 day period.


Post by marcio »

Hey MauriceLapre,

Glad that you figure it out! Thanks for sharing also the solution for future checking.

Best regards,
Márcio


Post by MauriceLapre »

No problem. Just one thing. On weeks and months, the first day (e.g. "first day of the week") is always Sunday. European calendar says the first day is Monday. Can I change that somewhere?


Post by marcio »

Do you mean the view?? Perhaps you're looking for https://www.bryntum.com/docs/gantt/api/Core/util/Month#config-weekStartDay

Best regards,
Márcio


Post Reply