Split a time period in seperate days for the calendar widget

0
I have a problem which I can't seem to solve, the situation is as follows: I'm using the calendar widget to display availability of certain orders, but when a order takes multiple days it messes up my layout. In order to solve this I would like to create a microflow that splits a time period that is longer than a day into smaller parts For example: Order A starts on monday 14:00 and ends on wednesday 10:00 I would like to substract (and create) the following objects from this 3 CalendaryObjects with: 1) First Startdate Monday 14:00 Enddate Monday 23:59 2) Second Startdate Tuesday 00:01 Endate Tuesday 23:59 3) THird Startdate Wednesday 00:01 Enddate Wednesday 10:00 I've come to the following solution but I am stuck and can't seem to figure out what to do next: Calculate the hours between start and end (44 in the case above) and create a variable for this Calculate the difference in hours from the startdate until the end of that day (which is where I am stuck, because I can't use ''EndOfCurrentDay'', is there any way to to ''EndOfCurrentDay'' for another date than today? Because then I can just keep making full day apointments until hours left < 24 and then create the last one. Any ideas?
asked
2 answers
0

Niels

If you have the beginning of a day in a variable, you can create another variable to contain end of day and use the addHours or addMinutes function to add the correct amount of time to get the end of day time you would like. In this way, you could build a loop that would maintain a variable with hours remaining, decrement hours remaining as you work your way through the days and finish when you are done processing your hours.

Hope that helps,

Mike

answered
0

Neils:

While I've only got limited experience with the Mendix Calendar Widget, one suggestion that may simplify things a bit is to use contiguous calendar events rather than a series of events with "annoying little gaps" between them. If you do this then the end of the current day is actually "the start of the next day" and your daily boundaries become the start of today, the start of tomorrow, the start of the next day, etc.

So, today is 14 October 2014 and starts at 00:00:00. The end of today is actually 15 October 2014 00:00:00 and has a duration of exactly 24 hours, 0 minutes, and 0 seconds.

So, in your case rather than splitting a multi-day calendar event into several that may have durations of 23H59M or 23H59M59S, I suggest splitting them into "touching" calendar events where one stops at 00:00:00 and the next one starts at 00:00:00.

I've at least confirmed in my test Mendix environment that a reservation that starts on 14 October 2014 00:00:00 and ends on 15 October 2014 at 00:00:00 is displayed only on October 14 and is naturally calculated as a duration of 24H00M00S.

Of course, if you adopt this approach and have a microflow that prevents overlapping reservations, you need to make your checks work so that a calendar event that ends at the same time that the next one begins is merely "touching" but not an overlapping pair of calendar events.

Good luck,

John

answered