/// <summary>
        /// Wholes the day condition for time zone.
        /// </summary>
        /// <param name="startDate">
        /// The Start date.
        /// </param>
        /// <param name="timeZone">
        /// The time zone.
        /// </param>
        /// <returns>
        /// The <see cref="UPInfoAreaCondition"/>.
        /// </returns>
        public UPInfoAreaCondition WholeDayConditionForTimeZone(DateTime startDate, UPCRMTimeZone timeZone)
        {
            var infoAreaId = this.InfoAreaMetaInfo.InfoAreaId;
            var timeString = timeZone.GetAdjustedCurrentMMTime(startDate);

            if (timeString == "0000")
            {
                return(new UPInfoAreaConditionLeaf(
                           infoAreaId,
                           this.DateFieldId,
                           timeZone.GetAdjustedCurrentMMDate(startDate)));
            }

            var date1 = new UPInfoAreaConditionLeaf(
                infoAreaId,
                this.DateFieldId,
                timeZone.GetAdjustedCurrentMMDate(startDate));
            var time1 = new UPInfoAreaConditionLeaf(infoAreaId, this.TimeFieldId, ">=", timeString);
            var date2 = new UPInfoAreaConditionLeaf(
                infoAreaId,
                this.DateFieldId,
                timeZone.GetAdjustedCurrentMMDate(startDate.AddSeconds(60 * 60 * 24)));
            var time2         = new UPInfoAreaConditionLeaf(infoAreaId, this.TimeFieldId, "<", timeString);
            var fromCondition = date1.InfoAreaConditionByAppendingAndCondition(time1);
            var toCondition   = date2.InfoAreaConditionByAppendingAndCondition(time2);

            return(fromCondition.InfoAreaConditionByAppendingOrCondition(toCondition));
        }
        /// <summary>
        /// Befores the date condition including time zone.
        /// </summary>
        /// <param name="date">
        /// The date.
        /// </param>
        /// <param name="including">
        /// if set to <c>true</c> [including].
        /// </param>
        /// <param name="timeZone">
        /// The time zone.
        /// </param>
        /// <returns>
        /// The <see cref="UPInfoAreaCondition"/>.
        /// </returns>
        public UPInfoAreaCondition BeforeDateCondition(DateTime date, bool including, UPCRMTimeZone timeZone)
        {
            string limitTime = timeZone.GetAdjustedCurrentMMTime(date);
            string limitDate = timeZone.GetAdjustedCurrentMMDate(date);

            if (limitTime == "0000" && !including)
            {
                return(new UPInfoAreaConditionLeaf(this.InfoAreaMetaInfo.InfoAreaId, this.DateFieldId, "<", limitDate));
            }

            if (limitTime == "2359" && including)
            {
                return(new UPInfoAreaConditionLeaf(this.InfoAreaMetaInfo.InfoAreaId, this.DateFieldId, "<=", limitDate));
            }

            var timeCondition = new UPInfoAreaConditionLeaf(
                this.InfoAreaMetaInfo.InfoAreaId,
                this.TimeFieldId,
                including ? "<=" : "<",
                limitTime);
            var dateCondition = new UPInfoAreaConditionLeaf(
                this.InfoAreaMetaInfo.InfoAreaId,
                this.DateFieldId,
                limitDate);
            var beforeDateCondition = new UPInfoAreaConditionLeaf(
                this.InfoAreaMetaInfo.InfoAreaId,
                this.DateFieldId,
                "<",
                limitDate);
            var cond = timeCondition.InfoAreaConditionByAppendingAndCondition(dateCondition);

            return(cond.InfoAreaConditionByAppendingOrCondition(beforeDateCondition));
        }
        /// <summary>
        /// Applies the time zone.
        /// </summary>
        /// <param name="timeZone">
        /// The time zone.
        /// </param>
        public override void ApplyTimeZone(UPCRMTimeZone timeZone)
        {
            if (this.DateCondition != null && this.TimeCondition != null)
            {
                var date = timeZone.DateFromClientDataMMDateStringTimeString(this.DateCondition.FirstValue, this.TimeCondition.FirstValue);
                if (date != null)
                {
                    this.DateCondition.ReplaceValue(timeZone.GetAdjustedCurrentMMDate(date.Value));
                    this.TimeCondition.ReplaceValue(timeZone.GetAdjustedCurrentMMTime(date.Value));
                }
            }
            else if (this.DateCondition != null)
            {
                var startDate = timeZone.DateFromClientDataMMDateStringTimeString(this.DateCondition.FirstValue, "0000");
                var endDate   = timeZone.DateFromClientDataMMDateStringTimeString(this.DateCondition.FirstValue, "2359")?.AddMinutes(60);

                if (startDate == DateTime.MinValue || endDate == DateTime.MinValue)
                {
                    return;
                }

                if (startDate != null && endDate != null)
                {
                    UPInfoAreaCondition replaceCondition;
                    if (this.DateCondition.CompareOperator == ">=")
                    {
                        replaceCondition = this.AfterDateCondition(startDate.Value, true, timeZone);
                    }
                    else if (this.DateCondition.CompareOperator == ">")
                    {
                        replaceCondition = this.AfterDateCondition(endDate.Value, false, timeZone);
                    }
                    else if (this.DateCondition.CompareOperator == "<=")
                    {
                        replaceCondition = this.BeforeDateCondition(endDate.Value, false, timeZone);
                    }
                    else if (this.DateCondition.CompareOperator == "<")
                    {
                        replaceCondition = this.BeforeDateCondition(startDate.Value, false, timeZone);
                    }
                    else if (this.DateCondition.CompareOperator == "<>")
                    {
                        var cond1 = this.BeforeDateCondition(startDate.Value, false, timeZone);
                        var cond2 = this.AfterDateCondition(endDate.Value, true, timeZone);
                        replaceCondition = cond1.InfoAreaConditionByAppendingOrCondition(cond2);
                    }
                    else
                    {
                        replaceCondition = this.WholeDayConditionForTimeZone(startDate.Value, timeZone);
                    }

                    if (replaceCondition != null)
                    {
                        this.ParentCondition.ReplaceConditionWithCondition(this.DateCondition, replaceCondition);
                    }
                }
            }
        }