Skip to content

Commit deb2409

Browse files
committed
- NonWorkingPeriod: added getter and setter for Duration
- Rotation: invalidated periods cache on AddSegment() - Team: renamed removeMember() to RemoveMember() - TimePeriod: fixed GetEnd() - WorkSchedule: fixed DeleteShift() - removed unused imports - Published to NuGet
1 parent 4dc5fcc commit deb2409

10 files changed

Lines changed: 22 additions & 31 deletions

File tree

-116 KB
Binary file not shown.

ShiftSharp/NonWorkingPeriod.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class NonWorkingPeriod : Named, IComparable<NonWorkingPeriod>
4646
/// <summary>
4747
/// duration of period
4848
/// </summary>
49-
public Duration Duration;
49+
public Duration Duration { get; set; }
5050

5151
/// <summary>
5252
/// Constructor

ShiftSharp/Properties/AssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
[assembly: AssemblyConfiguration("")]
1111
[assembly: AssemblyCompany("Point85")]
1212
[assembly: AssemblyProduct("ShiftSharp")]
13-
[assembly: AssemblyCopyright("Copyright © 2017")]
13+
[assembly: AssemblyCopyright("Copyright © 2017-2025")]
1414
[assembly: AssemblyTrademark("")]
1515
[assembly: AssemblyCulture("")]
1616

@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("2.0.0.0")]
36-
[assembly: AssemblyFileVersion("2.0.0.0")]
35+
[assembly: AssemblyVersion("2.1.1.0")]
36+
[assembly: AssemblyFileVersion("2.1.1.0")]

ShiftSharp/Rotation.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ public RotationSegment AddSegment(Shift startingShift, int daysOn, int daysOff)
171171
RotationSegment segment = new RotationSegment(startingShift, daysOn, daysOff, this);
172172
RotationSegments.Add(segment);
173173
segment.Sequence = RotationSegments.Count;
174+
// invalidate cache
175+
periods = null;
174176
return segment;
175177
}
176178

ShiftSharp/ShiftSharp.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
<Description>C# work schedule library</Description>
99
<Company>Point85</Company>
1010
<Product>ShiftSharp</Product>
11-
<Copyright>Copyright © 2017-2024</Copyright>
12-
<AssemblyVersion>2.1.0.0</AssemblyVersion>
13-
<FileVersion>2.1.0.0</FileVersion>
11+
<Copyright>Copyright © 2017-2025</Copyright>
12+
<AssemblyVersion>2.1.1.0</AssemblyVersion>
13+
<FileVersion>2.1.1.0</FileVersion>
1414
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
1515
<Title>Work schedule library</Title>
16-
<Version>2.1.0</Version>
16+
<Version>2.1.1</Version>
1717
<Authors>Kent Randall</Authors>
1818
<PackageId>ShiftSharp</PackageId>
1919
<PackageProjectUrl>https://github.com/point85/ShiftSharp</PackageProjectUrl>

ShiftSharp/Team.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2626
using System;
2727
using System.Collections.Concurrent;
2828
using System.Collections.Generic;
29-
using static System.Runtime.InteropServices.JavaScript.JSType;
3029

3130
namespace Point85.ShiftSharp.Schedule
3231
{
@@ -328,7 +327,7 @@ public void AddMember(TeamMember member)
328327
/// Remove a member from this team
329328
/// </summary>
330329
/// <param name="member">Team member</param>
331-
public void removeMember(TeamMember member)
330+
public void RemoveMember(TeamMember member)
332331
{
333332
if (this.AssignedMembers.Contains(member))
334333
{

ShiftSharp/TeamMember.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2525
using System;
2626
using System.Collections.Generic;
2727
using System.Linq;
28-
using System.Runtime.Intrinsics.X86;
2928
using System.Text;
3029
using System.Threading.Tasks;
3130

ShiftSharp/TeamMemberException.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2222
SOFTWARE.
2323
*/
2424
using NodaTime;
25-
using System;
26-
using System.Collections.Generic;
27-
using System.Linq;
28-
using System.Text;
29-
using System.Threading.Tasks;
30-
using static System.Runtime.InteropServices.JavaScript.JSType;
3125

3226
namespace Point85.ShiftSharp.Schedule
3327
{

ShiftSharp/TimePeriod.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ protected TimePeriod(string name, string description, LocalTime startTime, Durat
7777
/// <returns>Period end time</returns>
7878
public LocalTime GetEnd()
7979
{
80-
return StartTime.PlusSeconds((long)Duration.TotalSeconds);
80+
long totalSeconds = (long)Duration.TotalSeconds;
81+
long secondsInDay = totalSeconds % SECONDS_PER_DAY;
82+
return StartTime.PlusSeconds(secondsInDay);
8183
}
8284

8385
/// <summary>
@@ -93,7 +95,7 @@ public LocalTime GetEnd()
9395
/// <returns>Second in day</returns>
9496
public static int SecondOfDay(LocalTime time)
9597
{
96-
return (int)(time.NanosecondOfDay / 1E+09);
98+
return (int)(time.NanosecondOfDay / 1_000_000_000L);
9799
}
98100

99101
/// <summary>

ShiftSharp/WorkSchedule.cs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -279,23 +279,18 @@ public void DeleteShift(Shift shift)
279279
}
280280

281281
// can't be in use
282-
foreach (Shift inUseShift in Shifts)
282+
foreach (Team team in Teams)
283283
{
284-
foreach (Team team in Teams)
284+
Rotation rotation = team.Rotation;
285+
foreach (TimePeriod period in rotation.GetPeriods())
285286
{
286-
Rotation rotation = team.Rotation;
287-
288-
foreach (TimePeriod period in rotation.GetPeriods())
287+
if (period.Equals(shift))
289288
{
290-
if (period.Equals(inUseShift))
291-
{
292-
string msg = String.Format(WorkSchedule.GetMessage("shift.in.use"), shift.Name);
293-
throw new Exception(msg);
294-
}
289+
string msg = String.Format(WorkSchedule.GetMessage("shift.in.use"), shift.Name);
290+
throw new Exception(msg);
295291
}
296292
}
297293
}
298-
299294
Shifts.Remove(shift);
300295
}
301296

@@ -305,7 +300,7 @@ public void DeleteShift(Shift shift)
305300
/// <param name="name">Name</param>
306301
/// <param name="description">Description</param>
307302
/// <param name="startDateTime">Starting date and time of day</param>
308-
/// <param name="duration">Durtation of period</param>
303+
/// <param name="duration">Duration of period</param>
309304
/// <returns>NonWorkingPeriod</returns>
310305
public NonWorkingPeriod CreateNonWorkingPeriod(string name, string description, LocalDateTime startDateTime,
311306
Duration duration)

0 commit comments

Comments
 (0)