public void ProcessEarthCycle(NotificationState state, EarthCycle earth) { var sendFCM = ProcessSingleExpirable(state, earth, earth.StatType); if (sendFCM) { var ttl = earth.TimeLeft; var message = FCM.CreateMessage($"{earth.State.ToUpperFirst()} on Earth", $"{earth.TimeLeft.ToFormattedString()} left", platform, YawsNotification.Topic.EarthCycle, nameof(EarthCycle), ttl); NotificationMessages.Add(message); } }
public static string ToString(EarthCycle cycle) { var time = (cycle.expiry - DateTime.Now).Humanize(int.MaxValue, CultureInfo.GetCultureInfo("zh-CN"), TimeUnit.Hour, TimeUnit.Second, " "); var status = cycle.isDay ? "白天" : "夜晚"; var nextTime = !cycle.isDay ? "白天" : "夜晚"; var sb = new StringBuilder(); sb.AppendLine($"现在地球的时间是: {status}"); //sb.AppendLine($"将在 {cycle.Expiry} 变为 {nextTime}"); sb.Append($"距离 {nextTime} 还有 {time}"); return(sb.ToString()); }