Last active
August 29, 2015 14:16
-
-
Save pjsvis/0a543c0dc2e2490d11e3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ref: http://stackoverflow.com/questions/3738748/create-an-array-or-list-of-all-dates-between-two-dates | |
void Main() | |
{ | |
var requirements = GetRequirements(); | |
// TODO: Add a margin at the start and end | |
// Get a range of dates | |
var start = requirements.Select (x =>x.DtFm).Min(); | |
var end =requirements.Select (x =>x.DtTo).Max(); | |
var dateRange = Enumerable.Range(0, 1 + end.Subtract(start).Days) | |
.Select(offset => start.AddDays(offset)).OrderBy (offset =>offset.Date ) | |
.ToArray(); | |
Console.WriteLine(dateRange); | |
// TODO: Join with date, value data | |
} | |
// Define other methods and classes here | |
public class Requirement{ | |
public string Project{get;set;} | |
public DateTime DtFm{get;set;} | |
public DateTime DtTo{get;set;} | |
public int Amount{get;set;} | |
} | |
public List<Requirement> GetRequirements(){ | |
var requirements = new List<Requirement>{ | |
new Requirement{Project="DRA-71", DtFm=new DateTime(2012,11,19), DtTo=new DateTime(2014,6,29), Amount=2}, | |
new Requirement{Project="DRA-71", DtFm=new DateTime(2013,10,21), DtTo=new DateTime(2014,6,29), Amount=1}, | |
new Requirement{Project="ANR-008", DtFm=new DateTime(2013,9,9), DtTo=new DateTime(2014,3,30), Amount=3}, | |
new Requirement{Project="ODE-05", DtFm=new DateTime(2013,10,14), DtTo=new DateTime(2014,6,29), Amount=2}, | |
new Requirement{Project="URU-04", DtFm=new DateTime(2014,1,6), DtTo=new DateTime(2014,5,11), Amount=2}, | |
new Requirement{Project="EGY-003", DtFm=new DateTime(2014,9,1), DtTo=new DateTime(2014,11,4), Amount=1}, | |
}; | |
return requirements; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment