Working out how many hours worked after a certain time - c#

I am working on some custom rules in a time managment system and need to know how many hours in a shift have been before a certain time (19:00pm) and how many hours after. Shifts can start in the evening and finish in the morning so need to take that into account.
So far I have the below (this is just a snippet for one day) however it seems very clumsy and eloborate what I have written, can't help but feel I am missing a simpler solution, anyone have any ideas?
DateTime cutOffTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 19, 00, 00);
string cutOffTimeOfDay = GetTimeOfDayFromDateTime(cutOffTime);
double baseMondayHours = 10.00;
baseMondayHours = (baseMondayHours - 0.5);
if (GetTimeOfDayOnlyFromDateTime(monday.ShiftStart.Value) == "AM" && GetTimeOfDayOnlyFromDateTime(monday.ShiftEnd.Value) == "PM"
&& monday.ShiftEnd.Value.TimeOfDay < cutOffTime.TimeOfDay)
{
postCutOffMondayHours = 0;
baseMondayHours = monday.HoursWorked.Value;
}
else
{
string endTimeOfDay = GetTimeOfDayFromDateTime(monday.ShiftEnd.Value);
double hoursAfterCutOff = GetDuration(cutOffTimeOfDay, endTimeOfDay);
postCutOffMondayHours = hoursAfterCutOff;
baseMondayHours = (baseMondayHours - hoursAfterCutOff);
}
public static string GetTimeOfDayFromDateTime(DateTime d)
{
return d.ToString("HH:mm") + " " + d.ToString("tt", CultureInfo.InvariantCulture);
}
public static string GetTimeOfDayOnlyFromDateTime(DateTime d)
{
return d.ToString("tt", CultureInfo.InvariantCulture).ToUpper();
}
public static double GetDuration(string startTime, string endTime)
{
DateTime start = DateTime.Parse(startTime);
DateTime end = DateTime.Parse(endTime);
if (start > end)
end = end.AddDays(1);
TimeSpan duration = end.Subtract(start);
return duration.TotalHours;
}

I'm not sure if I'm missing something here, but isn't the built-in operator- of DateTime exactly what you're looking for? It returns the TimeSpan between the 2 DateTime, and if you can guarantee shiftStart < cutoffDateTime < shiftEnd, then you can get the hours worked by just using the TotalHours of TimeSpan (but adding that check is just an additional small if)
var shiftStart = new DateTime(2020, 6, 2, 17, 0, 0);
var shiftEnd = new DateTime(2020, 6, 3, 6, 30, 0);
var cutoffDateTime = new DateTime(2020, 6, 2, 19, 0, 0);
var hoursWorkedBefore = (cutoffDateTime - shiftStart).TotalHours;
var hoursWorkedAfter = (shiftEnd - cutoffDateTime).TotalHours;

Related

Week difference between 2 dates in C#

I'm trying to make a function in C# that returns the week difference between two dates. Its goal is to provide the same result of:
select datediff(ww,'2018-04-13','2018-04-16') as diff
In the example above there is only 3 days between these dates, but they are in different weeks, so the result should be 1.
I've tried to use .TotalDays but it's not working properly. I also tried .GetWeekOfYear but it won't return correctly when the year of the dates are different. I've seem many questions here on StackOverflow and on other forums and so far none of them match my case. This is the function I'm trying to far:
public static int GetWeekDiff(DateTime dtStart, DateTime dtEnd) {
// Doesn't work
var val = ((dtEnd - dtStart).TotalDays / 7);
val = Math.Ceiling(val);
return Convert.ToInt32(val);
// Doesn't work well between years
DateTimeFormatInfo dinfo = DateTimeFormatInfo.CurrentInfo;
var x = dinfo.Calendar.GetWeekOfYear(dtStart, CalendarWeekRule.FirstFullWeek, DayOfWeek.Monday);
var y = dinfo.Calendar.GetWeekOfYear(dtEnd, CalendarWeekRule.FirstFullWeek, DayOfWeek.Monday);
return y - x;
}
In the first part of my function, I tried what is described in this post. It didn't work
Can you help me?
Thanks in advance.
First figure how many days there are between the two dates. Divide the number of days by 7 to get full weeks.
Now figure out if there's an extra week to be counted by finding taking the number of days modulus 7 to get any remaining days. If the first date plus remaining days falls in a different week, add an extra week on to the count.
void Main()
{
var first = new DateTime(2018, 04, 13);
var second = new DateTime(2018, 04, 16);
Console.WriteLine(weekDiff(first, second));
}
public int weekDiff(DateTime d1, DateTime d2, DayOfWeek startOfWeek = DayOfWeek.Monday)
{
var diff = d2.Subtract(d1);
var weeks = (int)diff.Days / 7;
// need to check if there's an extra week to count
var remainingDays = diff.Days % 7;
var cal = CultureInfo.InvariantCulture.Calendar;
var d1WeekNo = cal.GetWeekOfYear(d1, CalendarWeekRule.FirstFullWeek, startOfWeek);
var d1PlusRemainingWeekNo = cal.GetWeekOfYear(d1.AddDays(remainingDays), CalendarWeekRule.FirstFullWeek, startOfWeek);
if (d1WeekNo != d1PlusRemainingWeekNo)
weeks++;
return weeks;
}
static void Main(string[] args)
{
DateTime date1 = new DateTime(2018, 04, 18);
DateTime date2 = new DateTime(2018, 04, 19);
System.Console.WriteLine((GetDiff(new DateTime(2018, 04, 18), new DateTime(2018, 04, 18)))); // 0
System.Console.WriteLine((GetDiff(new DateTime(2018, 04, 22), new DateTime(2018, 04, 23)))); // 1
System.Console.WriteLine((GetDiff(new DateTime(2018, 04, 16), new DateTime(2018, 04, 22)))); // 0
System.Console.WriteLine((GetDiff(new DateTime(2018, 04, 18), new DateTime(2018, 05, 03)))); // 2
}
private static int GetDiff(DateTime date1, DateTime date2)
{
date1 = SetDayToMonday(date1);
date2 = SetDayToMonday(date2);
return (int)((date2 - date1).TotalDays / 7);
}
private static DateTime SetDayToMonday(DateTime date)
{
var weekDay = date.DayOfWeek;
if (weekDay == DayOfWeek.Sunday)
return date.AddDays(-6);
else
return date.AddDays(-((int)weekDay-1));
}
First, set the day to the monday of the current week. Then count all full weeks(= /7 days as int). Easy as it is, it works probably across weeks and years.
See if this works. There could be more use cases that this doesn't cover, and the solution depends on how you define a week boundary (this assumes Sunday-Monday based on a comment above).
// Output:
// Weeks between 12/28/2017 and 1/10/2018: 2
// Weeks between 4/13/2018 and 4/16/2018: 1
// Weeks between 4/21/2018 and 4/22/2018: 0
// Weeks between 4/22/2018 and 4/23/2018: 1
void Main()
{
var datePairs = new List<KeyValuePair<DateTime, DateTime>>();
datePairs.Add(new KeyValuePair<DateTime, DateTime>(new DateTime(2017, 12, 28), new DateTime(2018, 1, 10)));
datePairs.Add(new KeyValuePair<DateTime, DateTime>(new DateTime(2018, 4, 13), new DateTime(2018, 4, 16)));
datePairs.Add(new KeyValuePair<DateTime, DateTime>(new DateTime(2018, 4, 21), new DateTime(2018, 4, 22)));
datePairs.Add(new KeyValuePair<DateTime, DateTime>(new DateTime(2018, 4, 22), new DateTime(2018, 4, 23)));
foreach (var datePair in datePairs)
{
var string1 = datePair.Key.ToShortDateString();
var string2 = datePair.Value.ToShortDateString();
Console.WriteLine($"Weeks between {string1} and {string2}: {GetWeekDiff(datePair.Key, datePair.Value)}");
}
}
public static int GetWeekDiff(DateTime dtStart, DateTime dtEnd)
{
var totalDays = (dtEnd - dtStart).TotalDays;
var weeks = (int)totalDays / 7;
var hasRemainder = totalDays % 7 > 0;
if (hasRemainder)
{
if (!(dtStart.DayOfWeek.Equals(DayOfWeek.Saturday) && dtEnd.DayOfWeek.Equals(DayOfWeek.Sunday)))
{
weeks++;
}
}
return weeks;
}
Maybe it can help
public static int GetIso8601WeekOfYear(DateTime time)
{
// Seriously cheat. If its Monday, Tuesday or Wednesday, then it'll
// be the same week# as whatever Thursday, Friday or Saturday are,
// and we always get those right
DayOfWeek day = CultureInfo.InvariantCulture.Calendar.GetDayOfWeek(time);
if (day >= DayOfWeek.Monday && day <= DayOfWeek.Wednesday)
{
time = time.AddDays(3);
}
// Return the week of our adjusted day
return CultureInfo.InvariantCulture.Calendar.GetWeekOfYear(time, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);
}
Get the correct week number of a given date
Can't comment yet and already used a flag on this post on something I believed to be similar. Here is another post I found that appears to align with the solution you are trying to create:
Get the number of calendar weeks between 2 dates in C#
This is my implementation to solve a similar problem, I haven't tested in thoroughly but it seems to work.
var dt1 = DateTime.Today.AddDays(-30);
var dt2 = DateTime.Today;
var noOfDays =(int) (dt2 - dt1).TotalDays;
int reminder;
var weeks = Math.DivRem(noOfDays, 7, out reminder);
weeks = reminder > 0 ? weeks + 1 : weeks;
It returns 1 week for 6 days or less gap, which is exactly what I needed.

How to find exact date range from list of date ranges by entering single date

I want to find the date range which falls in input date, following is structure
public class Duration
{
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
}
var durations = new List<Duration>();
var duration1 = new Duration()
{
StartDate = new DateTime(2017, 08, 1),
EndDate = new DateTime(2017, 08, 10)
};
durations.Add(duration1);
var duration2 = new Duration()
{
StartDate = new DateTime(2017, 08, 5),
EndDate = new DateTime(2017, 08, 10)
};
durations.Add(duration2);
var duration3 = new Duration()
{
StartDate = new DateTime(2017, 08, 5),
EndDate = new DateTime(2017, 08, 6)
};
durations.Add(duration3);
Now I want to find duration which is closest to the entered date for list of <Durations> with LINQ or for-loop
My expected result for currentDate=new DateTime(2017, 08, 7); is duration2
You first need to check if the currentDate is within the start and end dates of each range. For the ones that meet that condition, you calculate the "closeness" adding both distances. When you find one lapse(gap) smaller tan the previous, you save its index... and voilá
int lapse = Integer.MaxValue;
int counter = 0;
int index = 0;
foreach (d in durations) {
if (((d.StartDate <= currentDate) && (d.EndDate >= currentDate))) {
int newlapse = ((currentDate - d.StartDate).TotalDays + (d.EndDate - currentDate).TotalDays);
if ((newlapse < lapse)) {
lapse = newlapse;
index = counter;
}
}
counter +=1;
}
return durations(index);
If you need the middle of interval to be closest:
durations.OrderBy((d) => Math.Abs(d.EndDate.Ticks + d.StartDate.Ticks) / 2 - currentDate.Ticks).FirstOrDefault();
If you need the start of interval to be closest:
durations.OrderBy((d) => Math.Abs(d.EndDate.Ticks - currentDate.Ticks)).FirstOrDefault();
As D le mentioned above
First check if currentDate is within the start and end dates
Second select the duration with the minimal difference between start end end date
I used a nuget package called morelinq which gives nice extensions methods like MinBy:
var result = (from d in durations
where (d.StartDate <= currentDate && d.EndDate >= currentDate)
select d).MinBy(d => d.EndDate - d.StartDate);

DateTime go to first occurrence of hour/minute/second

Given this datetime of January 1 2015 at 23:00 hours:
var someDate = new DateTime(2015, 1, 1, 23, 0, 0);
And given the int 6, which is the desired hour, how do I return the first following datetime where the hour is 6? In this case, someDate and 6 would return a new DateTime of January 2 2015 at 06:00 hours.
I would simply add the hours to the original date and add another day if the result is before the original time:
var someDate = new DateTime(2015, 1, 1, 23, 0, 0);
var result = someDate.Date.AddHours(6); // note the "Date" part
if (result < someDate) result = result.AddDays(1);
You just have to add one day to the date and six hours to the result:
var someDate = new DateTime(2015, 1, 1, 23, 0, 0);
var result = someDate.Date.AddDays(1).AddHours(6);
Note the use of Date property - it will give you the start od the day and from there it's easy to navigate forward.
Try this:
while(someDate.Hour != 6){
someDate = someDate.AddHours(1);
}
Assuming you meant 24h clock, you can try this:
public DateTime GetDate(DateTime someDate,int hour)
{
return someDate.Hour>=hour? someDate.Date.AddDays(1).AddHours(6):someDate.Date.AddHours(6);
}
Something like this should do it:
public DateTime FollowingHour(DateTime start, int hour)
{
DateTime atHour = start.Date.AddHours(6);
if(atHour < start)
{
atHour += TimeSpan.FromDays(1);
}
return atHour;
}

In C#, what is the most elegant way to merge items in an array are part of a "single larger item"?

I have a C# app and I am pulling data from an external tracking system that tracks people requests and I store them in my database. So something like this:
public class Request
{
public DateTime Start {get;set;}
public DateTime End {get;set;}
public int PersonId {get;set;}
}
IEnumerable<Request> requests = GetExternalRequests();
The details of GetExternalRequests() are not relevant to the question.
The issue is that the service breaks things down to send me a request for every individual day (even if the request is a multi day request)
For example, if a person puts in a request for a full week (Monday to Friday), I get 5 different items in the array (each with a single date) and I would like to "merge" those into a single request with Start = Monday and End = Friday to avoid saving 5 different records into my database.
So far, I have what feels like a pretty inelegant solution now where I loop through all of the requests and put the results in a dictionary and then run the code below
IEnumerable<Request> requests = GetExternalRequests();
IEnumerable<Request> previousRequests = GetAllPreviousRequests();
Dictionary<string, Request> cachedDictionary = CacheAllRequestsByDateandPersonId(requests, previousRequests)
var groupedByPerson = requests.GroupBy(r=>r.PersonId);
foreach (var group in groupedByPerson)
{
foreach (Request request in group.OrderBy(r=>r.StartDate)
{
var offSet = 1;
if (request.StartDate.DayOfWeek == DayOfWeek.Friday)
{
offSet = 3;
}
if (cachedDictionary.ContainsKey(request.PersonId + request.StartDate.AddDays(offset))
{
//delete the request from the list and change the start date of the next request to the start date of this request.
}
}
}
so I wanted to get some suggestions to see if there is a more elegant way to "merge" these results.
To add some clarity (based on some comments below)
Requests cannot overlap (think vacation requests)
If I already have a previous request on Monday and a new request comes in on Tuesday then I also want to merge those
Assuming that your GetExternalRequests return some seed data like that
private static IEnumerable<Request> GetExternalRequests()
{
yield return new Request(new DateTime(2015, 1, 4), new DateTime(2015, 1, 4), 1);
yield return new Request(new DateTime(2015, 1, 5), new DateTime(2015, 1, 5), 1);
yield return new Request(new DateTime(2015, 1, 6), new DateTime(2015, 1, 6), 1);
yield return new Request(new DateTime(2015, 1, 7), new DateTime(2015, 1, 7), 1);
yield return new Request(new DateTime(2015, 1, 8), new DateTime(2015, 1, 8), 1);
yield return new Request(new DateTime(2015, 1, 11), new DateTime(2015, 1, 11), 1);
yield return new Request(new DateTime(2015, 1, 15), new DateTime(2015, 1, 15), 1);
yield return new Request(new DateTime(2015, 1, 19), new DateTime(2015, 1, 19), 1);
yield return new Request(new DateTime(2015, 1, 26), new DateTime(2015, 1, 26), 1);
yield return new Request(new DateTime(2015, 1, 4), new DateTime(2015, 1, 4), 2);
yield return new Request(new DateTime(2015, 1, 7), new DateTime(2015, 1, 7), 2);
}
Then you can merge your data using GroupBy, and then Aggregate to merge consecutive days
See the code below:
private static IList<Request> MergeRequests(IEnumerable<Request> requests)
{
return requests.GroupBy(r => r.PersonId)
.Aggregate(new Stack<Request>(), (list, grouping) =>
{
foreach (var request in grouping.OrderBy(r => r.StartDate))
{
var peek = list.Any() ? list.Peek() : null;
if (peek?.EndDate.Date.Day + 1 == request.StartDate.Date.Day)
peek.EndDate = request.EndDate;
else
list.Push(request);
}
return list;
})
.OrderBy(x => x.PersonId).ThenBy(x => x.StartDate)
.ToList();
}
So lets test this solution
public static void Main(string[] args)
{
Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US");
IEnumerable<Request> requests = GetExternalRequests();
var requestsMerge = MergeRequests(requests);
foreach (var request in requestsMerge)
Console.WriteLine($"Person Id: {request.PersonId} - StartDate: {request.StartDate} - EndDate: {request.EndDate}");
}
The output data is that:
Person Id: 1 - StartDate: 1/4/2015 12:00:00 AM - EndDate: 1/8/2015 12:00:00 AM
Person Id: 1 - StartDate: 1/11/2015 12:00:00 AM - EndDate: 1/12/2015 12:00:00 AM
Person Id: 1 - StartDate: 1/19/2015 12:00:00 AM - EndDate: 1/19/2015 12:00:00 AM
Person Id: 1 - StartDate: 1/26/2015 12:00:00 AM - EndDate: 1/26/2015 12:00:00 AM
Person Id: 2 - StartDate: 1/4/2015 12:00:00 AM - EndDate: 1/4/2015 12:00:00 AM
Person Id: 2 - StartDate: 1/7/2015 12:00:00 AM - EndDate: 1/7/2015 12:00:00 AM
You can try something like this:
public class Request
{
public DateTime Start { get; set; }
public DateTime End { get; set; }
public int PersonId { get; set; }
public Request(DateTime start)
{
while (!IsWorkingDay(start))
start = start.AddDays(1);
Start = start;
End = start.AddDays(1);
while (!IsWorkingDay(End))
End = End.AddDays(1);
}
private bool IsWorkingDay(DateTime date)
{
return date.DayOfWeek != DayOfWeek.Saturday && date.DayOfWeek != DayOfWeek.Sunday;
}
public bool Intersects(Request otherRequest)
{
if (otherRequest == this)
return true;
return !(otherRequest.End < Start || otherRequest.Start > End);
}
public void Merge(Request otherRequest)
{
if (otherRequest.Start < Start)
Start = otherRequest.Start;
if (otherRequest.End > End)
End = otherRequest.End;
}
}
And use it as follows:
var requests = GetExternalRequests().ToList();
var result = requests.GroupBy(g => g.PersonId)
.Select(g => g.OrderBy (r => r.Start)
.Aggregate(new List<Request>(),
(acc, right) => {
if (acc.Count > 0)
{
var lastItem = acc[acc.Count - 1];
if (lastItem.Intersects(right))
{
lastItem.Merge(right);
return acc;
}
}
acc.Add(right);
return acc;
}));
The Request class itself should be responsible for things like expanding over the weekend. This ensures you can't have a broken request.
cachedDictionary.Contains on a Dictionary<T, T> is a linq method, and it uses a brute force search. That is definitely the slowest part of the algorithm.
I suggest a change to the contents of your inner loop. Don't try to modify the requests in-place. Rather, build a new list of requests that only creates a new request when a non-consecutive day is encountered in the inner loop. The end of the request is set when the next request is started, or when the loop is complete.

C# get whole hour values between 2 datetime objects

I am trying to get the affected hours between 2 datetime and all i found was a python solution.
For example 'start' is 09:30 and 'end' is 14:00 (same day). The values I'd like returned are
[9:00, 10:00, 11:00, 12:00, 13:00, 14:00]
Python get whole hour values between 2 datetime objects
I can't seem to find any equivalent to C#.
So you want a list of all hours between both dates? You can use this query:
TimeSpan ts = dt2 - dt1;
IEnumerable<int> hoursBetween = Enumerable.Range(0, (int)ts.TotalHours)
.Select(i => dt1.AddHours(i).Hour);
Sample dates:
DateTime dt1 = new DateTime(2013, 07, 08, 15, 50, 00);
DateTime dt2 = new DateTime(2013, 07, 10, 19, 30, 00);
TimeSpan ts = dt2 - dt1;
IEnumerable<int> hoursBetween = Enumerable.Range(0, (int)ts.TotalHours)
.Select(i => dt1.AddHours(i).Hour);
foreach (int hour in hoursBetween)
Console.WriteLine(hour);
Output:
15
16
17
18
19
20
21
22
23
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
The following will return the total hours between the 2 DateTime objects:
(datevalue1 - datevalue2).TotalHours
And for a custom behavior,such as displaying a list of hours, use a simple custom method on that Timespan created to get a list of hours in your desired format.
Code suggestion of the top of my head:
public List<String> GenerateHours(DateTime t1,DateTime t2){
if ((t2-t1).TotalHours >24)){
//decide what to do.
return null;
}else{
var currentHour = t2.Hour;
var list = new List<String>();
for (int i=0;i<(t2-t1).TotalHours;i++){
if (currentHour<10){
list.Add("0"+currentHour+":00");
}else if (currentHour>=10){
list.Add(currentHour+":00");
}
currentHour= (currentHour+1)%24;
}
return list;
}
}
public IEnumerable<DateTime> GetHoursBetween(DateTime start, DateTime end)
{
DateTime first = start.Date.AddHours(start.Hour);
for (DateTime dateTime = first; dateTime <= end; dateTime = dateTime.AddHours(1))
{
yield return dateTime;
}
}
TimeSpan ts = DateTime1 - DateTime2;
double totalHours = ts.TotalHours;
From MSDN: "Gets the value of the current TimeSpan structure expressed in whole and fractional hours."
EDIT: ok, now I see what you're asking for. How about this:
var d1 = DateTime.Today.AddHours(9.5);
var d2 = DateTime.Today.AddHours(14);
var first = new DateTime(d1.Year, d1.Month, d1.Day, d1.Minute == 0 ? d1.Hour : d1.Hour + 1, 0, 0);
var second = new DateTime(d2.Year, d2.Month, d2.Day, d2.Minute == 0 ? d2.Hour : d2.Hour + 1, 0, 0);
TimeSpan ts = second - first;
//returns DateTimes affected. I.e., Today at, [10:00, 11:00, 12:00, 13:00, 14:00]
IEnumerable<DateTime> dates = Enumerable.Range(0, (int)ts.TotalHours + 1).Select(hour => first.AddHours(hour));
//Or, if you just want the HOURs
//returns just ints: i.e., DateTimes 10,11,12,13,14
IEnumerable<int> hours = Enumerable.Range(0, (int)ts.TotalHours + 1).Select(hour => first.AddHours(hour).Hour);
The first method is needed if you actually have dates that span days. If you DON'T, then the second method that just returns the hours would work fine.
This should do the trick. Tested in LinqPad.
var startDate = new DateTime(2013, 8, 7, 9, 30, 0);
var endDate = new DateTime(2013, 8, 7, 14, 0, 0);
List<string> times = new List<string>();
var currentTime = startDate;
if (currentTime.Minute != 0 || currentTime.Second != 0) {
// Get next hour
currentTime = currentTime.AddHours(1).AddMinutes(currentTime.Minute * -1);
}
while (currentTime <= endDate) {
times.Add(string.Format("{0:00}:00", currentTime.Hour));
currentTime = currentTime.AddHours(1);
}
(int)Math.Abs((date1 - date2).TotalHours)
Simply subtract them and get the total of hours from the result. Something like this:
var totalHours = (dateTime1 - dateTime2).TotalHours;
Maybe something like this would work?
public static List<DateTime> GetAffectedHours(DateTime start, DateTime end)
{
List<DateTime> result = new List<DateTime>();
// Strip start of its minutes/seconds/etc
DateTime initial = new DateTime(start.Year, start.Month, start.Day, start.Hour, 0, 0);
// Go ahead and get the next hour
DateTime iterator = initial.AddHours(1.0);
// if it is still before the end
while (iterator < end)
{
// add it to the results list
result.Add(iterator);
// and get the next hour
iterator = iterator.AddHours(1.0);
}
return result;
}
You can use a For loop
List<int> allHoursBetween = new List<int>();
for (DateTime d = myStartDate; d <= myEndDate; d = d.AddHours(1))
allHoursBetween.Add(d.Hour);

Categories