Skip to content

Commit 16f8729

Browse files
committed
updated README.md
1 parent f3c48fc commit 16f8729

File tree

4 files changed

+6
-181
lines changed

4 files changed

+6
-181
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Shift
2-
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.
1+
# ShiftSharp
2+
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.
33

44
## Concepts
55

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

225-
ShiftSharp, has the following structure:
225+
ShiftSharp has the following structure:
226226
* `/Documentation/html` Doxygen HTML files
227227
* `/bin/Release` compiled ShiftSharp.dll
228228
* `.` - C# source files

ShiftSharp.sln

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ Global
1414
Description = C# version of java Shift library
1515
EndGlobalSection
1616
GlobalSection(ProjectConfigurationPlatforms) = postSolution
17-
{0D3FF948-F5BE-4338-94CB-CDC1A4475159}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
18-
{0D3FF948-F5BE-4338-94CB-CDC1A4475159}.Debug|Any CPU.Build.0 = Debug|Any CPU
17+
{0D3FF948-F5BE-4338-94CB-CDC1A4475159}.Debug|Any CPU.ActiveCfg = Release|Any CPU
18+
{0D3FF948-F5BE-4338-94CB-CDC1A4475159}.Debug|Any CPU.Build.0 = Release|Any CPU
1919
{0D3FF948-F5BE-4338-94CB-CDC1A4475159}.Release|Any CPU.ActiveCfg = Release|Any CPU
2020
{0D3FF948-F5BE-4338-94CB-CDC1A4475159}.Release|Any CPU.Build.0 = Release|Any CPU
2121
{4EA986B7-7046-4501-B3EE-511FDC84D10E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU

ShiftSharp/bin/Release/ShiftSharp.dll

23 KB
Binary file not shown.

TestShiftSharp/TestSnippet.cs

+1-176
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2727
using NodaTime;
2828
using Point85.ShiftSharp.Schedule;
2929
using System;
30+
using System.Collections.Generic;
3031

3132
namespace TestShiftSharp
3233
{
@@ -36,183 +37,7 @@ public class TestSnippet : BaseTest
3637
[TestMethod]
3738
public void TestPartial()
3839
{
39-
schedule = new WorkSchedule("Working Time1", "Test working time");
40-
/*
41-
// shift does not cross midnight
42-
Duration shiftDuration = Duration.FromHours(8);
43-
LocalTime shiftStart = new LocalTime(7, 0, 0);
4440

45-
Shift shift = schedule.CreateShift("Work Shift1", "Working time shift", shiftStart, shiftDuration);
46-
LocalTime shiftEnd = shift.GetEnd();
47-
48-
// case #1
49-
Duration time = shift.CalculateWorkingTime(shiftStart.Minus(Period.FromHours(3)), shiftStart.Minus(Period.FromHours(2)));
50-
Assert.IsTrue(time.TotalSeconds == 0);
51-
time = shift.CalculateWorkingTime(shiftStart.Minus(Period.FromHours(3)), shiftStart.Minus(Period.FromHours(3)));
52-
Assert.IsTrue(time.TotalSeconds == 0);
53-
54-
// case #2
55-
time = shift.CalculateWorkingTime(shiftStart.Minus(Period.FromHours(1)), shiftStart.PlusHours(1));
56-
Assert.IsTrue(time.TotalSeconds == 3600);
57-
58-
// case #3
59-
time = shift.CalculateWorkingTime(shiftStart.PlusHours(1), shiftStart.PlusHours(2));
60-
Assert.IsTrue(time.TotalSeconds == 3600);
61-
62-
// case #4
63-
time = shift.CalculateWorkingTime(shiftEnd.Minus(Period.FromHours(1)), shiftEnd.PlusHours(1));
64-
Assert.IsTrue(time.TotalSeconds == 3600);
65-
66-
// case #5
67-
time = shift.CalculateWorkingTime(shiftEnd.PlusHours(1), shiftEnd.PlusHours(2));
68-
Assert.IsTrue(time.TotalSeconds == 0);
69-
time = shift.CalculateWorkingTime(shiftEnd.PlusHours(1), shiftEnd.PlusHours(1));
70-
Assert.IsTrue(time.TotalSeconds == 0);
71-
72-
// case #6
73-
time = shift.CalculateWorkingTime(shiftStart.Minus(Period.FromHours(1)), shiftEnd.PlusHours(1));
74-
Assert.IsTrue(time.TotalSeconds == shiftDuration.TotalSeconds);
75-
76-
// case #7
77-
time = shift.CalculateWorkingTime(shiftStart.PlusHours(1), shiftStart.PlusHours(1));
78-
Assert.IsTrue(time.TotalSeconds == 0);
79-
80-
// case #8
81-
time = shift.CalculateWorkingTime(shiftStart, shiftEnd);
82-
Assert.IsTrue(time.TotalSeconds == shiftDuration.TotalSeconds);
83-
84-
// case #9
85-
time = shift.CalculateWorkingTime(shiftStart, shiftStart);
86-
Assert.IsTrue(time.TotalSeconds == 0);
87-
88-
// case #10
89-
time = shift.CalculateWorkingTime(shiftEnd, shiftEnd);
90-
Assert.IsTrue(time.TotalSeconds == 0);
91-
92-
// case #11
93-
time = shift.CalculateWorkingTime(shiftStart, shiftStart.PlusSeconds(1));
94-
Assert.IsTrue(time.TotalSeconds == 1);
95-
96-
// case #12
97-
time = shift.CalculateWorkingTime(shiftEnd.Minus(Period.FromSeconds(1)), shiftEnd);
98-
Assert.IsTrue(time.TotalSeconds == 1);
99-
100-
// 8 hr shift crossing midnight
101-
shiftStart = new LocalTime(22, 0, 0);
102-
103-
shift = schedule.CreateShift("Work Shift2", "Working time shift", shiftStart, shiftDuration);
104-
shiftEnd = shift.GetEnd();
105-
106-
// case #1
107-
time = shift.CalculateWorkingTime(shiftStart.Minus(Period.FromHours(3)), shiftStart.Minus(Period.FromHours(2)), true);
108-
Assert.IsTrue(time.TotalSeconds == 0);
109-
time = shift.CalculateWorkingTime(shiftStart.Minus(Period.FromHours(3)), shiftStart.Minus(Period.FromHours(3)), true);
110-
Assert.IsTrue(time.TotalSeconds == 0);
111-
112-
// case #2
113-
time = shift.CalculateWorkingTime(shiftStart.Minus(Period.FromHours(1)), shiftStart.PlusHours(1), true);
114-
Assert.IsTrue(time.TotalSeconds == 3600);
115-
116-
// case #3
117-
time = shift.CalculateWorkingTime(shiftStart.PlusHours(1), shiftStart.PlusHours(2), true);
118-
Assert.IsTrue(time.TotalSeconds == 3600);
119-
120-
// case #4
121-
time = shift.CalculateWorkingTime(shiftEnd.Minus(Period.FromHours(1)), shiftEnd.PlusHours(1), false);
122-
Assert.IsTrue(time.TotalSeconds == 3600);
123-
124-
// case #5
125-
time = shift.CalculateWorkingTime(shiftEnd.PlusHours(1), shiftEnd.PlusHours(2), true);
126-
Assert.IsTrue(time.TotalSeconds == 0);
127-
time = shift.CalculateWorkingTime(shiftEnd.PlusHours(1), shiftEnd.PlusHours(1), true);
128-
Assert.IsTrue(time.TotalSeconds == 0);
129-
130-
// case #6
131-
time = shift.CalculateWorkingTime(shiftStart.Minus(Period.FromHours(1)), shiftEnd.PlusHours(1), true);
132-
Assert.IsTrue(time.TotalSeconds == shiftDuration.TotalSeconds);
133-
134-
// case #7
135-
time = shift.CalculateWorkingTime(shiftStart.PlusHours(1), shiftStart.PlusHours(1), true);
136-
Assert.IsTrue(time.TotalSeconds == 0);
137-
138-
// case #8
139-
time = shift.CalculateWorkingTime(shiftStart, shiftEnd, true);
140-
Assert.IsTrue(time.TotalSeconds == shiftDuration.TotalSeconds);
141-
142-
// case #9
143-
time = shift.CalculateWorkingTime(shiftStart, shiftStart, true);
144-
Assert.IsTrue(time.TotalSeconds == 0);
145-
146-
// case #10
147-
time = shift.CalculateWorkingTime(shiftEnd, shiftEnd, true);
148-
Assert.IsTrue(time.TotalSeconds == 0);
149-
150-
// case #11
151-
time = shift.CalculateWorkingTime(shiftStart, shiftStart.PlusSeconds(1), true);
152-
Assert.IsTrue(time.TotalSeconds == 1);
153-
154-
// case #12
155-
time = shift.CalculateWorkingTime(shiftEnd.Minus(Period.FromSeconds(1)), shiftEnd, false);
156-
Assert.IsTrue(time.TotalSeconds == 1);
157-
*/
158-
// 24 hr shift crossing midnight
159-
Duration shiftDuration = Duration.FromHours(24);
160-
LocalTime shiftStart = new LocalTime(7, 0, 0);
161-
162-
Shift shift = schedule.CreateShift("Work Shift3", "Working time shift", shiftStart, shiftDuration);
163-
LocalTime shiftEnd = shift.GetEnd();
164-
/*
165-
// case #1
166-
Duration time = shift.CalculateWorkingTime(shiftStart.Minus(Period.FromHours(3)), shiftStart.Minus(Period.FromHours(2)), false);
167-
Assert.IsTrue(time.TotalSeconds == 3600);
168-
time = shift.CalculateWorkingTime(shiftStart.Minus(Period.FromHours(3)), shiftStart.Minus(Period.FromHours(3)), true);
169-
Assert.IsTrue(time.TotalSeconds == 0);
170-
171-
// case #2
172-
time = shift.CalculateWorkingTime(shiftStart.Minus(Period.FromHours(1)), shiftStart.PlusHours(1), true);
173-
Assert.IsTrue(time.TotalSeconds == 3600);
174-
175-
// case #3
176-
time = shift.CalculateWorkingTime(shiftStart.PlusHours(1), shiftStart.PlusHours(2), true);
177-
Assert.IsTrue(time.TotalSeconds == 3600);
178-
179-
// case #4
180-
time = shift.CalculateWorkingTime(shiftEnd.Minus(Period.FromHours(1)), shiftEnd.PlusHours(1), true);
181-
Assert.IsTrue(time.TotalSeconds == 3600);
182-
183-
// case #5
184-
time = shift.CalculateWorkingTime(shiftEnd.PlusHours(1), shiftEnd.PlusHours(2), true);
185-
Assert.IsTrue(time.TotalSeconds == 3600);
186-
time = shift.CalculateWorkingTime(shiftEnd.PlusHours(1), shiftEnd.PlusHours(1), true);
187-
Assert.IsTrue(time.TotalSeconds == 0);
188-
189-
// case #6
190-
time = shift.CalculateWorkingTime(shiftStart.Minus(Period.FromHours(1)), shiftEnd.PlusHours(1), true);
191-
Assert.IsTrue(time.TotalSeconds == 3600);
192-
193-
// case #7
194-
time = shift.CalculateWorkingTime(shiftStart.PlusHours(1), shiftStart.PlusHours(1), true);
195-
Assert.IsTrue(time.TotalSeconds == 0);
196-
*/
197-
// case #8
198-
Duration time = shift.CalculateWorkingTime(shiftStart, shiftEnd, true);
199-
Assert.IsTrue(time.TotalSeconds == shiftDuration.TotalSeconds);
200-
201-
// case #9
202-
time = shift.CalculateWorkingTime(shiftStart, shiftStart, true);
203-
Assert.IsTrue(time.TotalSeconds == shiftDuration.TotalSeconds);
204-
205-
// case #10
206-
time = shift.CalculateWorkingTime(shiftEnd, shiftEnd, true);
207-
Assert.IsTrue(time.TotalSeconds == shiftDuration.TotalSeconds);
208-
209-
// case #11
210-
time = shift.CalculateWorkingTime(shiftStart, shiftStart.PlusSeconds(1), true);
211-
Assert.IsTrue(time.TotalSeconds == 1);
212-
213-
// case #12
214-
time = shift.CalculateWorkingTime(shiftEnd.Minus(Period.FromSeconds(1)), shiftEnd, false);
215-
Assert.IsTrue(time.TotalSeconds == 1);
21641
}
21742
}
21843
}

0 commit comments

Comments
 (0)