Jump to content

Shift Pattern not changing with Day Light saving


Swapnil G
Go to solution Solved by John Brezovec,

Recommended Posts

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:

image.thumb.png.8061a736dff5a8581df364bf312269b2.png

 

In the next step, I am defining my Night Shift using below formula:

image.png.988032b5b232203ad84cd649ea7ee0fd.png

And then I am defining my Days Shift using below formula:

image.png.cbdf8df564f99d6d6ed23ff3dc6c6d17.png

After this, I combined, the days and night condition:

$days.union($n)

Then I defined my first shift:

Shift A:

image.png.35de1a711f0cd04ec68b63aa021251e5.png

I then moved the next shift by 2 days, Shift B:

image.png.97e25babf8ce808c41193cc70fbd17fd.png

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.

image.thumb.png.508e146918e56998d43a6c0a8139def0.png

Please help, I referred guide from, but doesn't work for this shift pattern 

Link to comment
Share on other sites

  • Seeq Team
  • Solution

 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

image.thumb.png.eb2d7459e369196659ab6200c24ed771.png

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:

image.thumb.png.c04f5068c677a833c0562355d6ded05d.png

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...