private void CheckPCRRequirementSimple() { var required = false; var earliestSubmitTime = new DateTime(2020, 1, 1, 0, 0, 1); var testTimezone = WestCoastTimeZone; var it = Segments.Last(); var requireSampleDate = false; if (AirportDataset.TryGetAirportSimple(it.DepartureAirport, out var airport) && airport.PCRInAdvance != -1 && airport.StartTime <= it.LocalDepartureTime) { var airportTimeInLocal = TimeZoneInfo.ConvertTime(it.LocalDepartureTime, airport.TimeZone, testTimezone); var pcrTimeInLocal = airportTimeInLocal - new TimeSpan(airport.PCRInAdvance, 0, 0, 0); var earliestTime = new DateTime(pcrTimeInLocal.Year, pcrTimeInLocal.Month, pcrTimeInLocal.Day, 0, 1, 0); requireSampleDate = airport.UseSampleDateInstead && airport.UseSampleDateStartTime <= it.LocalDepartureTime; if (earliestTime > earliestSubmitTime) { required = true; earliestSubmitTime = earliestTime; } } if (required) { var dateType = requireSampleDate ? "采样日期" : "报告出具日期"; AddMessage("核酸码需要 " + dateType + " 为当地时间 " + earliestSubmitTime.ToString("yyyy/MM/dd") + " 及以后的报告。"); AddMessage("请注意,美国始发核酸报告出具时间会统一视作美西时间。请注意部分领事馆(如芝加哥)未按文字规定执行时差及相关规定,有可能无论中转地都需要字面日期减 3 的报告。"); } else { AddMessage("最终出发国家不需要核酸码,请使用高级版本计算结果,或改为选择美国出发,并填写离开美国那班航班的信息。"); } }
private void CheckPCRRequirement() { if (Segments.Count == 1 && AirportInJapan.Contains(Segments[0].DepartureAirport) && Segments[0].LocalDepartureTime >= new DateTime(2020, 9, 25, 0, 0, 1)) { AddMessage("日本直飞无需提供核酸码/14天打卡健康码,但是需要提供在指定核酸测试机构的纸质测试报告,并需持复印件供航空公司留存。详情请参阅资源一栏。"); return; } var required = false; var earliestSubmitTime = new DateTime(2020, 1, 1, 0, 0, 1); var isUsOrigin = AirportInUS.Contains(Segments[0].DepartureAirport); var hasOriginAirport = AirportDataset.TryGetAirport(Segments[0].DepartureAirport, out var originAirport); var testTimezone = isUsOrigin ? WestCoastTimeZone : PcrTimezone; var requireSampleDate = false; foreach (var it in Segments) { if (!AirportDataset.TryGetAirport(it.DepartureAirport, out var airport)) { continue; } if (airport.PCRInAdvance == -1 || airport.StartTime > it.LocalDepartureTime) { continue; } var countryRequireSampleDate = airport.UseSampleDateInstead && airport.UseSampleDateStartTime <= it.LocalDepartureTime; var airportTimeInLocal = TimeZoneInfo.ConvertTime(it.LocalDepartureTime, airport.TimeZone, testTimezone); var pcrTimeInLocal = airportTimeInLocal - new TimeSpan(airport.PCRInAdvance, 0, 0, 0); var earliestTime = new DateTime(pcrTimeInLocal.Year, pcrTimeInLocal.Month, pcrTimeInLocal.Day, 0, 1, 0); if (requireSampleDate) { if (earliestTime > earliestSubmitTime && countryRequireSampleDate) { required = true; earliestSubmitTime = earliestTime; } } else { if (earliestTime > earliestSubmitTime || countryRequireSampleDate) { required = true; earliestSubmitTime = earliestTime; if (countryRequireSampleDate) { requireSampleDate = true; } } } } if (required) { var dateType = requireSampleDate ? "采样日期" : "报告出具日期"; AddMessage("核酸码需要 " + dateType + " 为当地时间 " + earliestSubmitTime.ToString("yyyy/MM/dd") + " 及以后的报告。"); if (isUsOrigin) { AddMessage("请注意,美国始发核酸报告出具时间会统一视作美西时间。请注意部分领事馆(如芝加哥)未按文字规定执行时差及相关规定,有可能无论中转地都需要字面日期减 3 的报告。"); } if (hasOriginAirport) { earliestSubmitTime = TimeZoneInfo.ConvertTime(earliestSubmitTime, PcrTimezone, originAirport.TimeZone); if (earliestSubmitTime > Segments[0].LocalDepartureTime) { AddMessage("核酸报告时间无法赶上第一程航班。"); InvalidRoute(); return; } if ((Segments[0].LocalDepartureTime - earliestSubmitTime).TotalSeconds < 86400) { SuspiciousRoute(); AddMessage("报告出具时间到乘机不到 24 小时。有核酸码不能准时审核通过的风险。"); } } else { AddMessage("出发机场未知,无法判定核酸报告时间情况。"); } } else { AddMessage("不需要核酸码,请注意打小飞机。"); } }