mirror of
https://github.com/rafi1212122/BLHX.Server.git
synced 2025-12-13 06:54:51 +01:00
strictly necessary handlers
This commit is contained in:
14
BLHX.Server.Common/Utils/DateTimeExtensions.cs
Normal file
14
BLHX.Server.Common/Utils/DateTimeExtensions.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace BLHX.Server.Common.Utils
|
||||
{
|
||||
public static class DateTimeExtensions
|
||||
{
|
||||
public static int GetWeekOfMonth(this DateTime date)
|
||||
{
|
||||
int dayOfMonth = date.Day;
|
||||
DateTime firstDayOfMonth = new(date.Year, date.Month, 1);
|
||||
DayOfWeek firstDayOfWeek = firstDayOfMonth.DayOfWeek;
|
||||
int offset = (dayOfMonth + (int)firstDayOfWeek - 1) / 7;
|
||||
return offset + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user