26 lines
572 B
C#
26 lines
572 B
C#
namespace HotMap.Utils;
|
|
|
|
public static class UtilsExtensions
|
|
{
|
|
extension(DateOnly date)
|
|
{
|
|
public DateOnly GetMonday()
|
|
{
|
|
return date.DayOfWeek switch
|
|
{
|
|
DayOfWeek.Monday => date,
|
|
DayOfWeek.Sunday => date.AddDays(-6),
|
|
_ => date.AddDays(1 - (int)date.DayOfWeek)
|
|
};
|
|
}
|
|
}
|
|
|
|
extension<T>(IEnumerable<T> enumerable)
|
|
{
|
|
public IEnumerable<(T, int)> WithIndex()
|
|
{
|
|
return enumerable.Select((v, i) => (v, i));
|
|
}
|
|
}
|
|
}
|