Skip to content

Commit 61fb95c

Browse files
authored
Merge pull request #879 from kevinvenclovas/fixed-date-range-issue
fixed daterange split issue
2 parents 1cd4192 + 5e8862f commit 61fb95c

File tree

1 file changed

+21
-24
lines changed

1 file changed

+21
-24
lines changed

Source/FikaAmazonAPI/ReportGeneration/ReportDateRange.cs

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,27 @@ public class ReportDateRange
1010
public ReportDateRange(DateTime startDate, DateTime endDate) { StartDate = startDate; EndDate = endDate;}
1111

1212

13-
public static IList<ReportDateRange> GetDateRange(DateTime startDate, DateTime endDate, int MaxDays)
14-
{
15-
List<ReportDateRange> list = new List<ReportDateRange>();
16-
DateTime tempEnd = startDate;
17-
DateTime start = startDate;
18-
19-
while (true)
20-
{
21-
tempEnd = tempEnd.AddDays(MaxDays);
22-
if (tempEnd > endDate)
23-
{
24-
tempEnd = endDate;
25-
list.Add(new ReportDateRange(start, tempEnd));
26-
break;
27-
}
28-
else
29-
{
30-
list.Add(new ReportDateRange(start, tempEnd));
31-
start = tempEnd.AddSeconds(1);
32-
}
33-
34-
}
35-
36-
return list;
13+
public static IList<ReportDateRange> GetDateRange(DateTime startDate, DateTime endDate, int maxDays)
14+
{
15+
List<ReportDateRange> list = new List<ReportDateRange>();
16+
DateTime tempEnd;
17+
DateTime start = startDate;
18+
19+
while (start < endDate)
20+
{
21+
tempEnd = start.AddDays(maxDays);
22+
23+
if (tempEnd > endDate)
24+
{
25+
tempEnd = endDate;
26+
}
27+
28+
list.Add(new ReportDateRange(start, tempEnd));
29+
30+
start = tempEnd.AddSeconds(1);
31+
}
32+
33+
return list;
3734
}
3835
}
3936
}

0 commit comments

Comments
 (0)