Sub Activity_Create(FirstTime As Boolean)
Dim LastSunday As Long = GetPreviousDay(1)
Dim Monday As Long = DateTime.Add(LastSunday, 0, 0, -6)
'You probably want to set the time of LastSunday to 23:59:59
'LastSunday = DateUtils.SetDateAndTime(DateTime.GetYear(LastSunday), DateTime.GetMonth(LastSunday), _
' DateTime.GetDayOfMonth(LastSunday), 23, 59, 59)
Log("Monday: " & DateUtils.TicksToString(Monday))
Log("Sunday: " & DateUtils.TicksToString(LastSunday))
End Sub
'1 -> Sunday, 7-> Saturday
Sub GetPreviousDay(DayOfWeek As Int) As Long
Dim day As Int = DateTime.GetDayOfWeek(DateTime.Now)
If day <> DayOfWeek Then
day = (day + 7 - DayOfWeek) Mod 7
End If
Dim d As Long = DateTime.Add(DateTime.Now, 0, 0, -day)
Return DateUtils.SetDate(DateTime.GetYear(d), DateTime.GetMonth(d), DateTime.GetDayOfMonth(d))
End Sub