public static VirkningType Create(DateTime?fromDate, DateTime?toDate) { if (fromDate.HasValue && toDate.HasValue) { var effectiveToDate = toDate; // If date range boundaries contain no time componenbt if (toDate.Value.TimeOfDay.TotalMilliseconds == 0) { // Set toDate to end of day effectiveToDate = toDate.Value.AddDays(1).AddMilliseconds(-1); } if (effectiveToDate < fromDate) { throw new ArgumentException(string.Format("fromDate ({0}) should be less than or equal to toDate ({1})", fromDate, toDate)); } } return(new VirkningType() { //TODO: Fill actor AktoerRef = null, //TODO: Fill comment text CommentText = null, FraTidspunkt = TidspunktType.Create(fromDate), TilTidspunkt = TidspunktType.Create(toDate) }); }
public VirkningType ToVirkningType() { return(new VirkningType() { AktoerRef = UnikIdType.Clone(this.AktoerRef), CommentText = this.CommentText, FraTidspunkt = TidspunktType.Create(TidspunktType.ToDateTime(this.FraTidspunkt)), TilTidspunkt = null }); }
public static TilstandVirkningType Create(DateTime?fromDate) { return(new TilstandVirkningType() { //TODO: Fill actor AktoerRef = null, //TODO: Fill comment text CommentText = null, FraTidspunkt = TidspunktType.Create(fromDate) }); }
public bool Intersects(VirkningType otherEffect) { var v1 = VirkningType.Create(this.FraTidspunkt.ToDateTime(), this.TilTidspunkt.ToDateTime()); var v2 = VirkningType.Create(otherEffect.FraTidspunkt.ToDateTime(), otherEffect.TilTidspunkt.ToDateTime()); foreach (var v in new VirkningType[] { v1, v2 }) { if (!v.FraTidspunkt.ToDateTime().HasValue) { v.FraTidspunkt = TidspunktType.Create(DateTime.MinValue); } if (!v.TilTidspunkt.ToDateTime().HasValue) { v.TilTidspunkt = TidspunktType.Create(DateTime.MaxValue); } } return(v1.FraTidspunkt.ToDateTime().Value < v2.TilTidspunkt.ToDateTime().Value && v2.FraTidspunkt.ToDateTime().Value < v1.TilTidspunkt.ToDateTime().Value); }