Xin Calendar 2 Examples: Start date & end date II

  Start Date   End Date

This example is almost identical to the previous one except that we want a minimum 5-day interval between the Start Date and End Date.

To check whether the End Date is at least five days later than the Start Date, we "copy" a function from the Date Range mod:

function dateOffset(date,n) {
  var d=toJSDate(date||"");
  return toCalendarDate(d);

Here we are taking advantage of some helper functions, the dateOffset() function takes a date string parameter, converts it to a Javascript date object (toJSDate), adds the number of days to it (86400000 is the number of ms in a day) and converts it back to the calendar date (toCalendarDate).

Thus, we can compare dateOffset([ Start Date ], 5) to the [ End Date ] to see whether the End Date is good enough or not without worrying about the date format.

[Start date & end date III] [Back to index page]

# # #