[ItemNotNull] private async Task <string> GetTime([CanBeNull] string tz = null) { var extract = FuzzyParsing.TimeOffset(tz ?? ""); var offset = extract.IsValid ? extract.UtcOffset : TimeSpan.Zero; string FormatTime(DateTime dt) => (dt).ToString("HH:mm:ss tt"); if (extract.IsValid || tz == null) { return($"The time is {FormatTime(DateTime.UtcNow + offset)} UTC{offset.Hours:+00;-00;+00}:{offset.Minutes:00}"); } else { return($"I'm not sure what timezone you mean, assuming UTC it's {FormatTime(DateTime.UtcNow)}"); } }
private static string GetTime(string?tz = null) { var extract = FuzzyParsing.TimeOffset(tz ?? ""); var offset = extract.IsValid ? extract.UtcOffset : TimeSpan.Zero;