Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/OneScript.Native/Runtime/BuiltInFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down