fish-station/Content.Shared/_Sunrise/Time/TimeSystem.cs
Rinary 5d34b76518
Отображение даты в КПК (#47)
* Vulpkanin Lang Fix

* Date time add

* Time System

* Something fixes
2024-06-09 02:59:06 +03:00

44 lines
No EOL
1.2 KiB
C#

using Content.Shared.Examine;
using Content.Shared.GameTicking;
using Robust.Shared.Timing;
namespace Content.Shared._Sunrise.Time
{
public sealed class TimeSystem : EntitySystem
{
[Dependency] private readonly IGameTiming _timing = default!;
private TimeSpan _roundStart;
public override void Initialize()
{
base.Initialize();
SubscribeNetworkEvent<TickerLobbyStatusEvent>(LobbyStatus);
}
private void LobbyStatus(TickerLobbyStatusEvent ev)
{
_roundStart = ev.RoundStartTimeSpan;
}
public (TimeSpan Time, int Date) GetStationTime()
{
var stationTime = _timing.CurTime.Subtract(_roundStart).Add(TimeSpan.FromHours(12));
var date = 13;
while (stationTime.TotalHours >= 24)
{
stationTime.Subtract(TimeSpan.FromHours(24));
date = date + 1;
}
return (stationTime, date);
}
public string GetDate()
{
// please tell me you guys aren't gonna have a 4 week round yet...
return DateTime.UtcNow.AddYears(1000).ToString("dd.MM.yyyy");
}
}
}