aalhour / C-Sharp-Algorithms

:books: :chart_with_upwards_trend: Plug-and-play class-library project of standard Data Structures and Algorithms in C#
MIT License
5.91k stars 1.4k forks source link

Algorithm request: Get the Day of the Week from a Specific Date #164

Closed ChiaSuen closed 2 years ago

ChiaSuen commented 2 years ago

Is your algorithm request related to a computational problem? Please describe. I am working on some automation stuff, I need to get 1st, 2nd 3rd, 4th or last of specific weekdays in the month, so I plan to implement a code to get the day of the week with order (Ex: 1st Sunday, 2nd Monday...) from the date or get a date of specific day of the week from the month or year input.

Describe the solution you'd like For Get the Day of the Week from a Specific Date, I am going to get the dateValue.DayOfWeek from the DateTime parameter in the function then check if that DateTime -7 is from the same month or not to check on the occurrence of that particular weekday in the month previously. For get a date of specific day of the week from the month or year input, I am planning to do the similar stuff from before. Getting the 1st of the month, check dateValue.DayOfWeek add it according to the week of day want to find (1: Monday, 2: Tuesaday...) and the occurence wanted (1st, 2nd....) then proceed with DateTime + 7 with occurence count.

Describe alternatives you've considered Looping through the date of month to get first week of day needed.

Additional context Add any other context or screenshots about the feature request here.

github-actions[bot] commented 2 years ago

Thanks for supporting the development of C# Algorithms with your first issue! We look forward to handling it.

hoowee commented 2 years ago

您好,您的邮件我已经收到,会尽快处理,谢谢!中建八局设计管理总院 胡伟