private readonly double startDate_; // MillisecondsSince1970 UTC #endregion Fields #region Constructors /// <summary> /// Create a default RepetitiveInterval with one day duration, non-repeating. /// </summary> /// public RepetitiveInterval() { startDate_ = -System.Double.MaxValue; endDate_ = -System.Double.MaxValue; intervalStartHour_ = 0; intervalEndHour_ = 24; nRepeats_ = 0; repeatUnit_ = net.named_data.jndn.encrypt.RepetitiveInterval.RepeatUnit.NONE; }
/// <summary> /// Create a RepetitiveInterval with the given values. startDate must be /// earlier than or same as endDate. intervalStartHour must be less than /// intervalEndHour. /// </summary> /// /// <param name="startDate">The start date as milliseconds since Jan 1, 1970 UTC.</param> /// <param name="endDate">The end date as milliseconds since Jan 1, 1970 UTC.</param> /// <param name="intervalStartHour">The start hour in the day, from 0 to 23.</param> /// <param name="intervalEndHour">The end hour in the day from 1 to 24.</param> /// <param name="nRepeats"></param> /// <param name="repeatUnit"></param> /// <exception cref="System.Exception">if the above conditions are not met.</exception> public RepetitiveInterval(double startDate, double endDate, int intervalStartHour, int intervalEndHour, int nRepeats, RepetitiveInterval.RepeatUnit repeatUnit) { startDate_ = toDateOnlyMilliseconds(startDate); endDate_ = toDateOnlyMilliseconds(endDate); intervalStartHour_ = intervalStartHour; intervalEndHour_ = intervalEndHour; nRepeats_ = nRepeats; repeatUnit_ = repeatUnit; validate(); }
/// <summary> /// Create a RepetitiveInterval with the given values. startDate must be /// earlier than or same as endDate. intervalStartHour must be less than /// intervalEndHour. /// </summary> /// /// <param name="startDate">The start date as milliseconds since Jan 1, 1970 UTC.</param> /// <param name="endDate">The end date as milliseconds since Jan 1, 1970 UTC.</param> /// <param name="intervalStartHour">The start hour in the day, from 0 to 23.</param> /// <param name="intervalEndHour">The end hour in the day from 1 to 24.</param> /// <param name="nRepeats"></param> /// <param name="repeatUnit"></param> /// <exception cref="System.Exception">if the above conditions are not met.</exception> public RepetitiveInterval(double startDate, double endDate, int intervalStartHour, int intervalEndHour, int nRepeats, RepetitiveInterval.RepeatUnit repeatUnit) { startDate_ = toDateOnlyMilliseconds(startDate); endDate_ = toDateOnlyMilliseconds(endDate); intervalStartHour_ = intervalStartHour; intervalEndHour_ = intervalEndHour; nRepeats_ = nRepeats; repeatUnit_ = repeatUnit; validate(); }
/// <summary> /// Get the numeric value associated with the repeatUnit. This is a separate /// method for portability. /// </summary> /// /// <param name="repeatUnit">The RepeatUnit.</param> /// <returns>The numeric value for repeatUnit.</returns> public static int getRepeatUnitNumericType(RepetitiveInterval.RepeatUnit repeatUnit) { if (repeatUnit == net.named_data.jndn.encrypt.RepetitiveInterval.RepeatUnit.DAY) { return(1); } else if (repeatUnit == net.named_data.jndn.encrypt.RepetitiveInterval.RepeatUnit.MONTH) { return(2); } else if (repeatUnit == net.named_data.jndn.encrypt.RepetitiveInterval.RepeatUnit.YEAR) { return(3); } else { return(0); } }
/// <summary> /// Create a RepetitiveInterval with the given values, and no repetition. /// Because there is no repetition, startDate must equal endDate. /// intervalStartHour must be less than intervalEndHour. /// </summary> /// /// <param name="startDate">The start date as milliseconds since Jan 1, 1970 UTC.</param> /// <param name="endDate">The end date as milliseconds since Jan 1, 1970 UTC.</param> /// <param name="intervalStartHour">The start hour in the day, from 0 to 23.</param> /// <param name="intervalEndHour">The end hour in the day from 1 to 24.</param> /// <exception cref="System.Exception">if the above conditions are not met.</exception> public RepetitiveInterval(double startDate, double endDate, int intervalStartHour, int intervalEndHour) { startDate_ = toDateOnlyMilliseconds(startDate); endDate_ = toDateOnlyMilliseconds(endDate); intervalStartHour_ = intervalStartHour; intervalEndHour_ = intervalEndHour; nRepeats_ = 0; repeatUnit_ = net.named_data.jndn.encrypt.RepetitiveInterval.RepeatUnit.NONE; validate(); }
/// <summary> /// Create a RepetitiveInterval, copying values from the given repetitiveInterval. /// </summary> /// /// <param name="repetitiveInterval">The RepetitiveInterval to copy values from.</param> public RepetitiveInterval(RepetitiveInterval repetitiveInterval) { startDate_ = repetitiveInterval.startDate_; endDate_ = repetitiveInterval.endDate_; intervalStartHour_ = repetitiveInterval.intervalStartHour_; intervalEndHour_ = repetitiveInterval.intervalEndHour_; nRepeats_ = repetitiveInterval.nRepeats_; repeatUnit_ = repetitiveInterval.repeatUnit_; }