58 lines
1.6 KiB
C#
58 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace GWMS.UI.Data
|
|
{
|
|
public class SelectData
|
|
{
|
|
#region Public Properties
|
|
|
|
public DateTime DateEnd { get; set; } = DateTime.Now.AddMinutes(1);
|
|
public DateTime DateStart { get; set; } = DateTime.Now.AddDays(-7);
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Public Methods
|
|
|
|
/// <summary>
|
|
/// Inizializzazione con periodo e arrotondamento
|
|
/// </summary>
|
|
/// <param name="minRound"></param>
|
|
/// <param name="numDayPrev"></param>
|
|
/// <returns></returns>
|
|
public static SelectData Init(int minRound, int numDayPrev)
|
|
{
|
|
TimeSpan DayElapsed = DateTime.Now.Subtract(DateTime.Today);
|
|
int minDay = (int)((DayElapsed.TotalMinutes / minRound) + 1) * minRound;
|
|
DateTime endRounded = DateTime.Today.AddMinutes(minDay);
|
|
SelectData answ = new SelectData()
|
|
{
|
|
DateEnd = endRounded,
|
|
DateStart = endRounded.AddDays(-numDayPrev)
|
|
};
|
|
return answ;
|
|
}
|
|
|
|
public override bool Equals(object obj)
|
|
{
|
|
if (!(obj is SelectData item))
|
|
return false;
|
|
|
|
if (DateEnd != item.DateEnd)
|
|
return false;
|
|
if (DateStart != item.DateStart)
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
return base.GetHashCode();
|
|
}
|
|
|
|
#endregion Public Methods
|
|
}
|
|
} |