示例#1
0
文件: Time.cs 项目: Drelnoch/Mute
        [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)}");
            }
        }
示例#2
0
文件: Time.cs 项目: martindevans/Mute
 private static string GetTime(string?tz = null)
 {
     var extract = FuzzyParsing.TimeOffset(tz ?? "");
     var offset  = extract.IsValid ? extract.UtcOffset : TimeSpan.Zero;