next Week Day
Advances the specified date to the next weekday.
Controller: CodeCogs
Dependents
Interface
C++
NextWeekDay
intnextWeekDay( | int | nDate | |
bool | forward = true | )[inline] |
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:
Source Code
Source code is available when you agree to a GP Licence or buy a Commercial Licence.
Not a member, then Register with CodeCogs. Already a Member, then Login.