I am saving data into a circular log with designated byte multiples (dataSlots), and I'm calculating the week number based on the days that pass from a reference date.
DateTime startDate = DateTime.UtcNow;
for (int ii = 0; ii < 900; ii++)
{
currentDate = startDate + new TimeSpan(7 * ii, 1, 1, 1, 1)
DateTime globalStartReference = new DateTime(2011, 12, 1, 0, 0, 0, DateTimeKind.Utc);
var span = currentDate - globalStartReference ;
int dataSlot = 0;
dataSlot = (span.Days * 7) / 52;
Console.WriteLine(dataSlot);
}
My hope is that dataSlot will be an ever-increasing number based upon the current week, however it isn't. I get duplicate entries (and therefore overwrite my data) on these weeks
11
28
44
60
77
88
109
Why am I getting duplicate weeks and how do I account for this? My guess is that there is a fractional number of weeks in a year...