![]() Var pastWeeks = test. Var totalWeeks = test.TotalWeeksThisYear() My console was used to test class Program TimeSpan daysBetween = FirstSunday_ThisYear - FirstSunday_LastYear TimeSpan daysBetween = FirstSunday_NextYear - FirstSunday_ThisYear TimeSpan daysBetween = ThisSunday - FirstSunday_LastYear TimeSpan daysBetween = ThisSunday - FirstSunday_ThisYear If (IsDateInFirstWeek(checkDay) = false)Įlse if(ThisSunday > FirstSunday_ThisYear) Var checkDay = GetSundayDate(suppliedDate) Private DateTime GetSundayDate_WeekOne(DateTime suppliedDate) While (checkDay.DayOfWeek != DayOfWeek.Sunday) Check if the day of the supplied date is a Sunday Private DateTime GetSundayDate(DateTime suppliedDate) Apakah Anda lagi mencari bacaan seputar Calendar Week Number namun belum ketemu Tepat sekali pada kesempatan kali ini admin blog mulai membahas artikel, dokumen ataupun file tentang Calendar Week Number yang sedang kamu cari saat ini dengan lebih baik. First week must contain a Thursday, so lowest Sunday date possible is the 4th Private bool IsDateInFirstWeek(DateTime suppliedDate) Throw new Exception("Incorrect date has been supplied") If (DateTime.TryParse(weekDate, out _weekDate)) Private DateTime FirstSunday_NextYear => GetSundayDate_WeekOne(FirstDay_NextYear) Private DateTime FirstSunday_LastYear => GetSundayDate_WeekOne(FirstDay_LastYear) ![]() Private DateTime FirstSunday_ThisYear => GetSundayDate_WeekOne(FirstDay_ThisYear) Private DateTime FirstDay_ThisYear => DateTime.Parse($"01/01/") Private DateTime ThisSunday => GetSundayDate(_weekDate) With this is mind (and I am very new to C# and all the intricacies) I wrote this code which will give you the week number of any given date and also the number of weeks for this year and the previous. If you assume that Sunday is the last day of the week, then the lowest date for Sunday has to be the 4th. From what I have found, the first week of the year must contain a Thursday. ![]() I have looked at this as well when I was writing an application in LotusNotes. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |