File tree Expand file tree Collapse file tree 1 file changed +21
-18
lines changed
Source/FikaAmazonAPI/ReportGeneration Expand file tree Collapse file tree 1 file changed +21
-18
lines changed Original file line number Diff line number Diff line change @@ -10,27 +10,30 @@ public class ReportDateRange
10
10
public ReportDateRange ( DateTime startDate , DateTime endDate ) { StartDate = startDate ; EndDate = endDate ; }
11
11
12
12
13
- public static IList < ReportDateRange > GetDateRange ( DateTime startDate , DateTime endDate , int MaxDays )
14
- {
15
- List < ReportDateRange > list = new List < ReportDateRange > ( ) ;
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 ;
16
18
17
- double totalDays = ( endDate - startDate ) . TotalDays ;
18
- int range = ( int ) ( totalDays / MaxDays ) ;
19
- int remind = ( int ) ( totalDays % MaxDays ) ;
20
- if ( remind > 0 )
21
- range ++ ;
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
+ }
22
33
23
- for ( int i = 0 ; i < range ; i ++ )
24
- {
25
- var newStartDate = startDate . AddDays ( i * MaxDays ) ;
26
- var newEndDate = newStartDate . AddDays ( MaxDays ) ;
27
- if ( i == range - 1 )
28
- newEndDate = endDate ;
34
+ }
29
35
30
- list . Add ( new ReportDateRange ( newStartDate , newEndDate ) ) ;
31
- }
32
-
33
- return list ;
36
+ return list ;
34
37
}
35
38
}
36
39
}
You can’t perform that action at this time.
0 commit comments