FUNCTION
nextWeekDay
Advances the specified date to the next weekday.
Interface
#include <codecogs/units/date/nextweekday.h>
using namespace Units::Date;
This function advances the provided date to the next weekday, ensuring that it lies between Monday and Friday.
Example 1
To compute the Christmas and New Year holidays:
#include <stdio.h>
#include <codecogs/units/date/nextweekday.h>
#include <codecogs/units/date/date.h>
using namespace Units::Date;
int main()
{
int holidays[4];
holidays[0] = date("24 dec 2005"); // If your lucky!
holidays[1] = nextWeekDay(date("25 dec 2005")-1); // Christmas or if a weekend the next Monday.
holidays[2] = nextWeekDay(holidays[1]); // next weekday after Christmas (Boxing day).
holidays[3] = nextWeekDay(date("1 jan 2006")-1); // New year.
return 0;
}Remember that nextWeekDay automatically increments the date, so even if the give date is already a weekday it still advances - we therefore fool nextWeekDay by putting -1 after date , so it gives us the specified date or if a weekend the next weekday.
Parameters
nDate
is a serial number of days from 24 November 4714 BC (1 January 4713BC in the Julian Calendar) - also known as the Julian Period.
forward
is a boolean that controls which direction the next week day is found in:
Interactive Calculator
nDate
forward
Result
Computing…
Set a range above first to export a graph.
This function's source code is only visible to registered users — documentation and the calculator above are free to use either way. Sign in to see it.