diff --git a/src/OneScript.Native/Runtime/BuiltInFunctions.cs b/src/OneScript.Native/Runtime/BuiltInFunctions.cs index 1bb5c2e3f..861209f24 100644 --- a/src/OneScript.Native/Runtime/BuiltInFunctions.cs +++ b/src/OneScript.Native/Runtime/BuiltInFunctions.cs @@ -265,6 +265,12 @@ public static int StrEntryCount(string where, string what) [ContextMethod("НачалоМесяца", "BegOfMonth")] public static DateTime BegOfMonth(DateTime date) => new DateTime(date.Year, date.Month, 1); + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [ContextMethod("НачалоНедели", "BegOfWeek")] + public static DateTime BegOfWeek(DateTime date) + => new DateTime(date.Year, date.Month, date.Day) + .AddDays(-((int)date.DayOfWeek+6)%7); + [MethodImpl(MethodImplOptions.AggressiveInlining)] [ContextMethod("НачалоДня", "BegOfDay")] public static DateTime BegOfDay(DateTime date) => new DateTime(date.Year, date.Month, date.Day); @@ -321,6 +327,12 @@ public static DateTime EndOfMonth(DateTime date) return new DateTime(year, month, DateTime.DaysInMonth(year, month), 23, 59, 59); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [ContextMethod("КонецНедели", "EndOfWeek")] + public static DateTime EndOfWeek(DateTime date) + => new DateTime(date.Year, date.Month, date.Day, 23, 59, 59) + .AddDays((7-(int)date.DayOfWeek) % 7); + [MethodImpl(MethodImplOptions.AggressiveInlining)] [ContextMethod("КонецДня", "EndOfDay")] public static DateTime EndOfDay(DateTime date) => new DateTime(date.Year, date.Month, date.Day, 23, 59, 59);