namespace Fitness_core_BE.Helpers { // Every gym this runs for is Sri Lanka-based -- shared by SubscriptionRenewalJob (daily // trigger wake-up) and the Classes feature (converting a class's local StartTimeOfDay to // UTC per generated occurrence). Lifted out of SubscriptionRenewalJob rather than each // caller re-deriving it. public static class TimeZoneHelper { public static readonly TimeZoneInfo SriLanka = ResolveSriLankaTimeZone(); private static TimeZoneInfo ResolveSriLankaTimeZone() { try { return TimeZoneInfo.FindSystemTimeZoneById("Sri Lanka Standard Time"); // Windows ID } catch (TimeZoneNotFoundException) { try { return TimeZoneInfo.FindSystemTimeZoneById("Asia/Colombo"); // IANA ID (Linux/macOS) } catch (TimeZoneNotFoundException) { // Neither ID resolved (e.g. no tzdata on the host) -- Sri Lanka has kept a // fixed UTC+5:30 offset with no DST since 2006, so a custom fixed-offset // zone is a safe fallback rather than failing the whole caller. return TimeZoneInfo.CreateCustomTimeZone( "Sri Lanka (fixed +05:30)", TimeSpan.FromMinutes(330), "Sri Lanka Time", "Sri Lanka Time"); } } } } }