viewed 1738 times and licensed 17 times
Advances the specified date to the next weekday.
View version details
Contents  |
|
Interface
#include <codecogs/units/date/nextweekday.h>
using namespace Units::Date;
| int | nextWeekDay (int nDate, bool forward=true)[inline] Advances the specified date to the next weekday. |
Function Documentation
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 ...) , 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: |
Page Comments
You must login to leave a messge
Last Modified: 18 Feb 09 @ 10:56 Page Rendered: 2010-03-11 14:23:58