mirror of
https://github.com/simtactics/mysimulation.git
synced 2025-07-06 14:40:28 -04:00
Removed NioTSO client and server
- NioTSO client isn't needed because we're using RayLib - Added FreeSO's API server to handle most backend operations
This commit is contained in:
parent
f12ba1502b
commit
22191ce648
591 changed files with 53264 additions and 3362 deletions
50
server/FSO.Server.Database/DA/LotVisits/LotVisitUtils.cs
Executable file
50
server/FSO.Server.Database/DA/LotVisits/LotVisitUtils.cs
Executable file
|
@ -0,0 +1,50 @@
|
|||
using System;
|
||||
|
||||
namespace FSO.Server.Database.DA.LotVisits
|
||||
{
|
||||
public static class LotVisitUtils
|
||||
{
|
||||
/// <summary>
|
||||
/// Calculates the overlap between two date ranges.
|
||||
/// Useful utility function for calculating visit hours.
|
||||
/// </summary>
|
||||
/// <param name="day"></param>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="end"></param>
|
||||
public static TimeSpan CalculateDateOverlap(DateTime r1_start, DateTime r1_end, DateTime r2_start, DateTime r2_end)
|
||||
{
|
||||
var startsInRange = r2_start >= r1_start && r2_start <= r1_end;
|
||||
var endsInRange = r2_end <= r1_end && r2_end >= r1_start;
|
||||
|
||||
if (startsInRange && endsInRange)
|
||||
{
|
||||
//Within the range / equal
|
||||
return r2_end.Subtract(r2_start);
|
||||
}
|
||||
else if (startsInRange)
|
||||
{
|
||||
//Starts within range but does not end in range
|
||||
return r1_end.Subtract(r2_start);
|
||||
}
|
||||
else if (endsInRange)
|
||||
{
|
||||
//Ends in range but does not start in range
|
||||
return r2_end.Subtract(r1_start);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TimeSpan(0);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns midnight of the current day.
|
||||
/// Useful utility function for calculating visit hours.
|
||||
/// </summary>
|
||||
public static DateTime Midnight()
|
||||
{
|
||||
var now = DateTime.UtcNow;
|
||||
return new DateTime(now.Year, now.Month, now.Day, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue