15 lines
675 B
C#
15 lines
675 B
C#
using System.Globalization;
|
|||
|
|
|
||
|
|
namespace Helpdesk.Web.Infrastructure;
|
||
|
|
|
||
|
|
/// <summary>API vrací časy v UTC; uživatelům je zobrazujeme v českém čase (kap. 12.6 návrhu).</summary>
|
||
|
|
public static class DisplayTime
|
||
|
|
{
|
||
|
|
private static readonly TimeZoneInfo Prague = TimeZoneInfo.FindSystemTimeZoneById("Europe/Prague");
|
||
|
|
private static readonly CultureInfo Czech = CultureInfo.GetCultureInfo("cs-CZ");
|
||
|
|
|
||
|
|
public static DateTimeOffset ToLocal(DateTimeOffset utc) => TimeZoneInfo.ConvertTime(utc, Prague);
|
||
|
|
|
||
|
|
/// <summary>Např. „3. 10. 2026 14:05“.</summary>
|
||
|
|
public static string Format(DateTimeOffset utc) => ToLocal(utc).ToString("d. M. yyyy H:mm", Czech);
|
||
|
|
}
|