
Ok. Here is the scenario.
We have a Dayshift and a Nightshift.
Arbitrarily, Dayshift starts at 07:00 and ends at 19:00. And obviously, Nightshift starts at 19:00 and runs until 07:00 the next morning.
While this can change the Dayshift Start and End Times are stored in System Settings.
The user enter a start TimeStamp and an End TimeStamp. For example… Start April 5 2017 02:30 and End April 22 2017 20:15
Notes:
1. The Start and End Time and be ANY time, either Dayshift or Nightshift (either PM or AM).
2. The Start and End Time could possibly be within the same Shift on the same Date or they could be any number of days/shifts apart.
So…. the challenge is…..
Given a Start and End TimeStamp, Create A Record for EVERY Shift (including partial shifts) between the Start and End Time.
For example: for the Start Timestamp above, April 5 2017 02:30, the first record that needs to be created will look like…
05/04/17 02:30 05/04/17 07:00 NS
and the last record will look like…
22/04/17 19:00 22/04/17 20:15 NS
AND we need to create a record for EVERY shift in between.
On the surface this seems like a very trivial problem. However, as you dig deeper into it, the more complex it becomes. Why?
Firstly, a Nightshift can start on one of two dates but still have a Workdate being the previous day if starting in the AM hours and the current day if starting in the PM hours.
There are numerous permutations and combinations for the start and finish.
Date Ranges can have no shift, 1 shift or many shifts between the start and end timestamps.
The solution needs to traverse across the Date Range creating all intermediate shifts for both Dayshift and Nightshift.
Anyway, for those interested, I have additionally uploaded my design logic notes and the final bsv.
There is some good examples in there in how to pull apart and construct timestamp and also it demonstrates how you can push more and more work up into the BO Rules so as to simplify Processes.
Enjoy.
AwareIM Version: v7
Dependencies:
Where:
Script: Complex TimeStamp Rules and Processes