diff --git a/src/BreCalClient/MainWindow.xaml.cs b/src/BreCalClient/MainWindow.xaml.cs index f9aaa80..c00efee 100644 --- a/src/BreCalClient/MainWindow.xaml.cs +++ b/src/BreCalClient/MainWindow.xaml.cs @@ -582,12 +582,45 @@ namespace BreCalClient if(sfm.EtaFrom != null) { - _ = this._visibleControlModels.RemoveAll(x => x.Shipcall?.Eta < sfm.EtaFrom); + _ = this._visibleControlModels.RemoveAll(x => + { + Times? t = x.GetTimesForParticipantType(ParticipantType.AGENCY); + switch (x.Shipcall?.Type) + { + case (int)Extensions.TypeEnum.Incoming: + { + if ((t != null) && t.EtaBerth.HasValue) return t.EtaBerth.Value < sfm.EtaFrom; + return x.Shipcall?.Eta < sfm.EtaFrom; + } + default: // Shifting / Departing + { + if ((t != null) && t.EtdBerth.HasValue) return t.EtdBerth.Value < sfm.EtaFrom; + return x.Shipcall?.Etd < sfm.EtaFrom; + } + } + }); } if(sfm.EtaTo != null) { - _ = this._visibleControlModels.RemoveAll(x => x.Shipcall?.Eta > sfm.EtaTo); + _ = this._visibleControlModels.RemoveAll(x => + { + Times? t = x.GetTimesForParticipantType(ParticipantType.AGENCY); + DateTime refValue = sfm.EtaTo.Value.AddMinutes(1439); // 23:59 + switch (x.Shipcall?.Type) + { + case (int)Extensions.TypeEnum.Incoming: + { + if ((t != null) && t.EtaBerth.HasValue) return t.EtaBerth.Value > refValue; + return x.Shipcall?.Eta > refValue; + } + default: // Shifting / Departing + { + if ((t != null) && t.EtdBerth.HasValue) return t.EtdBerth.Value > refValue; + return x.Shipcall?.Etd > refValue; + } + } + }); } if(!_showCanceled ?? true) // canceled calls are filtered by default