@@ -265,6 +265,12 @@ public static int StrEntryCount(string where, string what)
265265 [ ContextMethod ( "НачалоМесяца" , "BegOfMonth" ) ]
266266 public static DateTime BegOfMonth ( DateTime date ) => new DateTime ( date . Year , date . Month , 1 ) ;
267267
268+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
269+ [ ContextMethod ( "НачалоНедели" , "BegOfWeek" ) ]
270+ public static DateTime BegOfWeek ( DateTime date )
271+ => new DateTime ( date . Year , date . Month , date . Day )
272+ . AddDays ( - ( ( int ) date . DayOfWeek + 6 ) % 7 ) ;
273+
268274 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
269275 [ ContextMethod ( "НачалоДня" , "BegOfDay" ) ]
270276 public static DateTime BegOfDay ( DateTime date ) => new DateTime ( date . Year , date . Month , date . Day ) ;
@@ -321,6 +327,12 @@ public static DateTime EndOfMonth(DateTime date)
321327 return new DateTime ( year , month , DateTime . DaysInMonth ( year , month ) , 23 , 59 , 59 ) ;
322328 }
323329
330+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
331+ [ ContextMethod ( "КонецНедели" , "EndOfWeek" ) ]
332+ public static DateTime EndOfWeek ( DateTime date )
333+ => new DateTime ( date . Year , date . Month , date . Day , 23 , 59 , 59 )
334+ . AddDays ( ( 7 - ( int ) date . DayOfWeek ) % 7 ) ;
335+
324336 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
325337 [ ContextMethod ( "КонецДня" , "EndOfDay" ) ]
326338 public static DateTime EndOfDay ( DateTime date ) => new DateTime ( date . Year , date . Month , date . Day , 23 , 59 , 59 ) ;
0 commit comments