c# - TimeSpan for different years substracted from a bigger TimeSpan -


the language using c#.

i have folowing dillema.

datetime a, datetime b. if < b have calculate number of days per year in timespan , multiply coeficient corresponds year. problem fact can span multiple years.

for example:

nr of days in timespan 2009 * coef 2009 + nr of days in timespan 2010 * coef 2010 + etc

here little snippet of code might help

    var start = new datetime(2009, 10, 12);     var end = new datetime(2014, 12, 25);      var s = j in enumerable.range(start.year, end.year + 1 - start.year)             let _start = start.year == j ? start : new datetime(j, 1, 1)             let _end = end.year == j ? end : new datetime(j, 12, 31)             select new {                  year = j,                 days = convert.toint32((_end - _start).totaldays) + 1                                 }; 

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -