IW4M-Admin/SharedLibraryCore/Helpers/PlayerHistory.cs

40 lines
1.0 KiB
C#
Raw Normal View History

2015-04-27 13:40:57 -04:00
using System;
using SharedLibraryCore.Dtos;
2015-04-27 13:40:57 -04:00
2018-04-08 02:44:42 -04:00
namespace SharedLibraryCore.Helpers
2015-04-27 13:40:57 -04:00
{
public class PlayerHistory
2015-04-27 13:40:57 -04:00
{
// how many minutes between updates
public static readonly int UpdateInterval = 5;
2022-01-26 11:32:16 -05:00
private readonly DateTime When;
public PlayerHistory(int cNum)
2015-04-27 13:40:57 -04:00
{
2022-01-26 11:32:16 -05:00
var t = DateTime.UtcNow;
When = new DateTime(t.Year, t.Month, t.Day, t.Hour,
Math.Min(59, UpdateInterval * (int)Math.Round(t.Minute / (float)UpdateInterval)), 0);
y = cNum;
}
/// <summary>
2022-01-26 11:32:16 -05:00
/// Used by CanvasJS as a point on the x axis
/// </summary>
2022-01-26 11:32:16 -05:00
public string x => When.ToString("yyyy-MM-ddTHH:mm:ssZ");
/// <summary>
2022-01-26 11:32:16 -05:00
/// Used by CanvasJS as a point on the y axis
/// </summary>
public int y { get; }
public ClientCountSnapshot ToClientCountSnapshot()
{
return new ClientCountSnapshot
{
ClientCount = y,
Time = When
};
}
2015-04-27 13:40:57 -04:00
}
2022-01-26 11:32:16 -05:00
}