Swapnil G Posted October 30, 2023 Share Posted October 30, 2023 Hi all, I am based in the UK and wanted to define shift pattern that changes with time zones. I have created a condition for a 12 hour shifts that are on days for 2 consecutive days and then on nights for 2 consecutive nights. [Each shift will have 4 working days (2 days and 2 nights and 4 days off] Consider 4 shifts in this shift pattern, namely: Shift 1, Shift 2, Shift 3, Shift 4. The shift starts at 8am and ends at 20:00. After which the next shift starts at 20:00 and ends at 8:00 I am using the following formula: In the next step, I am defining my Night Shift using below formula: And then I am defining my Days Shift using below formula: After this, I combined, the days and night condition: $days.union($n) Then I defined my first shift: Shift A: I then moved the next shift by 2 days, Shift B: And then used this shift to define next one and so on, by moving each shift by 2 days from previous one. The issue I am having is that the shift is not aligned with daylight saving. Please help, I referred guide from, but doesn't work for this shift pattern Link to comment Share on other sites More sharing options...
Seeq Team John Brezovec Posted October 30, 2023 Seeq Team Share Posted October 30, 2023 By default, functions like periods and shifts will use UTC time. There is an optional timeZone argument to these functions that will make them timezone/DST aware. An example from the documentation: periods(4year, 4year, '2021-01-20T12:00:00', 'America/New_York') Link to comment Share on other sites More sharing options...
Swapnil G Posted October 30, 2023 Author Share Posted October 30, 2023 Hi John, thank you for the response. Could you please help me with how can I use this in my example to get shifts aligned and updated with time zones? Link to comment Share on other sites More sharing options...
Seeq Team Solution John Brezovec Posted October 30, 2023 Seeq Team Solution Share Posted October 30, 2023 Looking at this again, since your schedule is a little simpler than EOWeO, I'd create this condition a little differently. I'd represent each shift as a union (AND) of several smaller periodic conditions. For example, the day shifts for Shift A in your company could be represented as times when all the following conditions are present: Day Shifts (08:00-20:00 every day) 4 Days On (A periodic condition 4 days long that occurs every 8 days) First 2 Days of the 4 Days On (Periodic condition 2 days long that occurs every 4 days) Visually Shift A would look like: the AND of all the conditions marked with 1 the AND of all the conditions marked with 2 Then you can shift that condition by increments of 2 days to get the other three of your shifts. We can put this all into one formula that looks like: $shift_identifier = 'A' // TODO: change this identifier $offset = 0d // TODO: Change offset for each shift $tz = 'Europe/London' $days = shifts(8, 12, $tz) $nights = shifts(20, 12, $tz) $on4 = periods(4d, 8d, toTime('2000-01-01T08:00:00Z') + $offset, $tz) $first2 = periods(2d, 4d, toTime('2000-01-01T08:00:00Z') + $offset, $tz) $second2 = periods(2d, 4d, toTime('2000-01-01T08:00:00Z') + 2d + $offset, $tz) combineWith( $days and $on4 and $first2, $nights and $on4 and $second2 ).setProperty('Shift', $shift_identifier) You would copy this four times, one for each shift, adjusting the shift identifier as well as the offset. I'm adjusting the offset directly within the periods() function in order to keep everything DST aware rather than using the move() function, which can mess up when DST takes effect. The final result of this looks like this: Link to comment Share on other sites More sharing options...
Swapnil G Posted October 31, 2023 Author Share Posted October 31, 2023 Hi John. This works like a charm. Thanks alot. 🙂 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now