Skip to content

Commit

Permalink
ch: whitespace fixes and rmeoval of unused classes
Browse files Browse the repository at this point in the history
  • Loading branch information
bolorundurowb committed Oct 4, 2020
1 parent a976db4 commit ced7b62
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 28 deletions.
23 changes: 0 additions & 23 deletions src/Enums/SeekPosition.cs

This file was deleted.

12 changes: 7 additions & 5 deletions src/FinalSpan.cs
Expand Up @@ -7,34 +7,36 @@ namespace moment.net
public class FinalSpan
{
private DateTime _dt;
private DayOfWeek _dow;
private readonly DayOfWeek _dayOfWeek;

public FinalSpan(DateTime dateTime, DayOfWeek dayOfWeek)
{
_dt = dateTime;
_dow = dayOfWeek;
_dayOfWeek = dayOfWeek;
}

public DateTime InMonth()
{
var m = _dt.Month;
// only loop through the last seven days of the month
_dt = new DateTime(_dt.Year,_dt.Month, (DateTime.DaysInMonth(_dt.Year, _dt.Month)-7), 0, 0, 0, _dt.Kind);
_dt = new DateTime(_dt.Year, _dt.Month, (DateTime.DaysInMonth(_dt.Year, _dt.Month) - 7), 0, 0, 0, _dt.Kind);
while (_dt.Month == m)
{
if(_dt.DayOfWeek == _dow)
if (_dt.DayOfWeek == _dayOfWeek)
{
return _dt;
}

_dt = _dt.AddDays(1);
}

return DateTime.MaxValue;
}

public DateTime InYear()
{
var dt = new DateTime(_dt.Year, 12, (DateTime.DaysInMonth(_dt.Year, 12) - 7), 0, 0, 0, _dt.Kind);
return new FinalSpan(dt, _dow).InMonth();
return new FinalSpan(dt, _dayOfWeek).InMonth();
}
}
}

0 comments on commit ced7b62

Please sign in to comment.