- New control: MonthPicker - New control TreeView - adding examples for all 3 - small change on Progress Bar Control - due latest changes on the base it is now easier to create controls which will be rendered (or not)in several forms depending on user context
37 lines
944 B
C#
37 lines
944 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace TelegramBotBase.Tools
|
|
{
|
|
public static class Time
|
|
{
|
|
public static DateTime StartOfWeek(this DateTime dt, DayOfWeek startOfWeek)
|
|
{
|
|
int diff = dt.DayOfWeek - startOfWeek;
|
|
if (diff < 0)
|
|
{
|
|
diff += 7;
|
|
}
|
|
return dt.AddDays(-1 * diff).Date;
|
|
}
|
|
|
|
public static DateTime EndOfWeek(this DateTime dt, DayOfWeek startOfWeek)
|
|
{
|
|
return StartOfWeek(dt, startOfWeek).AddDays(6);
|
|
}
|
|
|
|
public static DateTime FirstDayOfMonth(this DateTime date)
|
|
{
|
|
return new DateTime(date.Year, date.Month, 1);
|
|
}
|
|
|
|
public static DateTime LastDayOfMonth(this DateTime date)
|
|
{
|
|
return FirstDayOfMonth(date).AddMonths(1).AddDays(-1);
|
|
}
|
|
}
|
|
}
|