Skip to content

Commit

Permalink
updated README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
point85 committed Oct 25, 2017
1 parent f3c48fc commit 16f8729
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 181 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Shift
The Shift library project manages work schedules. A work schedule consists of one or more teams who rotate through a sequence of shift and off-shift periods of time. The Shift project allows breaks during shifts to be defined as well as non-working periods of time (e.g. holidays and scheduled maintenance periods) that are applicable to the entire work schedule. The C# project is a port of the java project at https://github.com/point85/Shift.
# ShiftSharp
The ShiftSharp library project manages work schedules. A work schedule consists of one or more teams who rotate through a sequence of shift and off-shift periods of time. The ShiftSharp project allows breaks during shifts to be defined as well as non-working periods of time (e.g. holidays and scheduled maintenance periods) that are applicable to the entire work schedule. The C# project is a port of the java project at https://github.com/point85/Shift.

## Concepts

Expand Down Expand Up @@ -222,7 +222,7 @@ Working shifts
## Project Structure
ShiftSharp depends upon .Net Framework 4.5+ due to use of the NodaTime date and time classes.

ShiftSharp, has the following structure:
ShiftSharp has the following structure:
* `/Documentation/html` Doxygen HTML files
* `/bin/Release` compiled ShiftSharp.dll
* `.` - C# source files
Expand Down
4 changes: 2 additions & 2 deletions ShiftSharp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Global
Description = C# version of java Shift library
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0D3FF948-F5BE-4338-94CB-CDC1A4475159}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0D3FF948-F5BE-4338-94CB-CDC1A4475159}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0D3FF948-F5BE-4338-94CB-CDC1A4475159}.Debug|Any CPU.ActiveCfg = Release|Any CPU
{0D3FF948-F5BE-4338-94CB-CDC1A4475159}.Debug|Any CPU.Build.0 = Release|Any CPU
{0D3FF948-F5BE-4338-94CB-CDC1A4475159}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0D3FF948-F5BE-4338-94CB-CDC1A4475159}.Release|Any CPU.Build.0 = Release|Any CPU
{4EA986B7-7046-4501-B3EE-511FDC84D10E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
Expand Down
Binary file added ShiftSharp/bin/Release/ShiftSharp.dll
Binary file not shown.
177 changes: 1 addition & 176 deletions TestShiftSharp/TestSnippet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
using NodaTime;
using Point85.ShiftSharp.Schedule;
using System;
using System.Collections.Generic;

namespace TestShiftSharp
{
Expand All @@ -36,183 +37,7 @@ public class TestSnippet : BaseTest
[TestMethod]
public void TestPartial()
{
schedule = new WorkSchedule("Working Time1", "Test working time");
/*
// shift does not cross midnight
Duration shiftDuration = Duration.FromHours(8);
LocalTime shiftStart = new LocalTime(7, 0, 0);

Shift shift = schedule.CreateShift("Work Shift1", "Working time shift", shiftStart, shiftDuration);
LocalTime shiftEnd = shift.GetEnd();
// case #1
Duration time = shift.CalculateWorkingTime(shiftStart.Minus(Period.FromHours(3)), shiftStart.Minus(Period.FromHours(2)));
Assert.IsTrue(time.TotalSeconds == 0);
time = shift.CalculateWorkingTime(shiftStart.Minus(Period.FromHours(3)), shiftStart.Minus(Period.FromHours(3)));
Assert.IsTrue(time.TotalSeconds == 0);
// case #2
time = shift.CalculateWorkingTime(shiftStart.Minus(Period.FromHours(1)), shiftStart.PlusHours(1));
Assert.IsTrue(time.TotalSeconds == 3600);
// case #3
time = shift.CalculateWorkingTime(shiftStart.PlusHours(1), shiftStart.PlusHours(2));
Assert.IsTrue(time.TotalSeconds == 3600);
// case #4
time = shift.CalculateWorkingTime(shiftEnd.Minus(Period.FromHours(1)), shiftEnd.PlusHours(1));
Assert.IsTrue(time.TotalSeconds == 3600);
// case #5
time = shift.CalculateWorkingTime(shiftEnd.PlusHours(1), shiftEnd.PlusHours(2));
Assert.IsTrue(time.TotalSeconds == 0);
time = shift.CalculateWorkingTime(shiftEnd.PlusHours(1), shiftEnd.PlusHours(1));
Assert.IsTrue(time.TotalSeconds == 0);
// case #6
time = shift.CalculateWorkingTime(shiftStart.Minus(Period.FromHours(1)), shiftEnd.PlusHours(1));
Assert.IsTrue(time.TotalSeconds == shiftDuration.TotalSeconds);
// case #7
time = shift.CalculateWorkingTime(shiftStart.PlusHours(1), shiftStart.PlusHours(1));
Assert.IsTrue(time.TotalSeconds == 0);
// case #8
time = shift.CalculateWorkingTime(shiftStart, shiftEnd);
Assert.IsTrue(time.TotalSeconds == shiftDuration.TotalSeconds);
// case #9
time = shift.CalculateWorkingTime(shiftStart, shiftStart);
Assert.IsTrue(time.TotalSeconds == 0);
// case #10
time = shift.CalculateWorkingTime(shiftEnd, shiftEnd);
Assert.IsTrue(time.TotalSeconds == 0);
// case #11
time = shift.CalculateWorkingTime(shiftStart, shiftStart.PlusSeconds(1));
Assert.IsTrue(time.TotalSeconds == 1);
// case #12
time = shift.CalculateWorkingTime(shiftEnd.Minus(Period.FromSeconds(1)), shiftEnd);
Assert.IsTrue(time.TotalSeconds == 1);
// 8 hr shift crossing midnight
shiftStart = new LocalTime(22, 0, 0);
shift = schedule.CreateShift("Work Shift2", "Working time shift", shiftStart, shiftDuration);
shiftEnd = shift.GetEnd();
// case #1
time = shift.CalculateWorkingTime(shiftStart.Minus(Period.FromHours(3)), shiftStart.Minus(Period.FromHours(2)), true);
Assert.IsTrue(time.TotalSeconds == 0);
time = shift.CalculateWorkingTime(shiftStart.Minus(Period.FromHours(3)), shiftStart.Minus(Period.FromHours(3)), true);
Assert.IsTrue(time.TotalSeconds == 0);
// case #2
time = shift.CalculateWorkingTime(shiftStart.Minus(Period.FromHours(1)), shiftStart.PlusHours(1), true);
Assert.IsTrue(time.TotalSeconds == 3600);
// case #3
time = shift.CalculateWorkingTime(shiftStart.PlusHours(1), shiftStart.PlusHours(2), true);
Assert.IsTrue(time.TotalSeconds == 3600);
// case #4
time = shift.CalculateWorkingTime(shiftEnd.Minus(Period.FromHours(1)), shiftEnd.PlusHours(1), false);
Assert.IsTrue(time.TotalSeconds == 3600);
// case #5
time = shift.CalculateWorkingTime(shiftEnd.PlusHours(1), shiftEnd.PlusHours(2), true);
Assert.IsTrue(time.TotalSeconds == 0);
time = shift.CalculateWorkingTime(shiftEnd.PlusHours(1), shiftEnd.PlusHours(1), true);
Assert.IsTrue(time.TotalSeconds == 0);
// case #6
time = shift.CalculateWorkingTime(shiftStart.Minus(Period.FromHours(1)), shiftEnd.PlusHours(1), true);
Assert.IsTrue(time.TotalSeconds == shiftDuration.TotalSeconds);
// case #7
time = shift.CalculateWorkingTime(shiftStart.PlusHours(1), shiftStart.PlusHours(1), true);
Assert.IsTrue(time.TotalSeconds == 0);
// case #8
time = shift.CalculateWorkingTime(shiftStart, shiftEnd, true);
Assert.IsTrue(time.TotalSeconds == shiftDuration.TotalSeconds);
// case #9
time = shift.CalculateWorkingTime(shiftStart, shiftStart, true);
Assert.IsTrue(time.TotalSeconds == 0);
// case #10
time = shift.CalculateWorkingTime(shiftEnd, shiftEnd, true);
Assert.IsTrue(time.TotalSeconds == 0);
// case #11
time = shift.CalculateWorkingTime(shiftStart, shiftStart.PlusSeconds(1), true);
Assert.IsTrue(time.TotalSeconds == 1);
// case #12
time = shift.CalculateWorkingTime(shiftEnd.Minus(Period.FromSeconds(1)), shiftEnd, false);
Assert.IsTrue(time.TotalSeconds == 1);
*/
// 24 hr shift crossing midnight
Duration shiftDuration = Duration.FromHours(24);
LocalTime shiftStart = new LocalTime(7, 0, 0);

Shift shift = schedule.CreateShift("Work Shift3", "Working time shift", shiftStart, shiftDuration);
LocalTime shiftEnd = shift.GetEnd();
/*
// case #1
Duration time = shift.CalculateWorkingTime(shiftStart.Minus(Period.FromHours(3)), shiftStart.Minus(Period.FromHours(2)), false);
Assert.IsTrue(time.TotalSeconds == 3600);
time = shift.CalculateWorkingTime(shiftStart.Minus(Period.FromHours(3)), shiftStart.Minus(Period.FromHours(3)), true);
Assert.IsTrue(time.TotalSeconds == 0);
// case #2
time = shift.CalculateWorkingTime(shiftStart.Minus(Period.FromHours(1)), shiftStart.PlusHours(1), true);
Assert.IsTrue(time.TotalSeconds == 3600);
// case #3
time = shift.CalculateWorkingTime(shiftStart.PlusHours(1), shiftStart.PlusHours(2), true);
Assert.IsTrue(time.TotalSeconds == 3600);
// case #4
time = shift.CalculateWorkingTime(shiftEnd.Minus(Period.FromHours(1)), shiftEnd.PlusHours(1), true);
Assert.IsTrue(time.TotalSeconds == 3600);
// case #5
time = shift.CalculateWorkingTime(shiftEnd.PlusHours(1), shiftEnd.PlusHours(2), true);
Assert.IsTrue(time.TotalSeconds == 3600);
time = shift.CalculateWorkingTime(shiftEnd.PlusHours(1), shiftEnd.PlusHours(1), true);
Assert.IsTrue(time.TotalSeconds == 0);
// case #6
time = shift.CalculateWorkingTime(shiftStart.Minus(Period.FromHours(1)), shiftEnd.PlusHours(1), true);
Assert.IsTrue(time.TotalSeconds == 3600);
// case #7
time = shift.CalculateWorkingTime(shiftStart.PlusHours(1), shiftStart.PlusHours(1), true);
Assert.IsTrue(time.TotalSeconds == 0);
*/
// case #8
Duration time = shift.CalculateWorkingTime(shiftStart, shiftEnd, true);
Assert.IsTrue(time.TotalSeconds == shiftDuration.TotalSeconds);

// case #9
time = shift.CalculateWorkingTime(shiftStart, shiftStart, true);
Assert.IsTrue(time.TotalSeconds == shiftDuration.TotalSeconds);

// case #10
time = shift.CalculateWorkingTime(shiftEnd, shiftEnd, true);
Assert.IsTrue(time.TotalSeconds == shiftDuration.TotalSeconds);

// case #11
time = shift.CalculateWorkingTime(shiftStart, shiftStart.PlusSeconds(1), true);
Assert.IsTrue(time.TotalSeconds == 1);

// case #12
time = shift.CalculateWorkingTime(shiftEnd.Minus(Period.FromSeconds(1)), shiftEnd, false);
Assert.IsTrue(time.TotalSeconds == 1);
}
}
}

0 comments on commit 16f8729

Please sign in to comment.