Documentation - Example 1
DOCUMENTATION FOR UNITS::DATE::WEEK OF YEAR
This example shows most of main uses of Doxygen, including the introduction of equations. Sometime its more logical to put most of the documentation with the Submitted Code, rather than in the Detailed Description. The following lines will show this:
Brief Description
Computes the week number of a date - ISO, Excel and Simple standards implemented.
Gives this:
Interface |
|
#include <codecogs/units/date/date.h> | |
int | Units::Date::weekOfYear (int nDate, weekNumStd Standard=wkn_ISO, int Mode=1) |
Computes the week number of a date - ISO, Excel and Simple standards implemented. Excel: WEEKNUM. |
Detailed Description
This function returns the week number within the Gregorian calendar only. There are three main standards: \copydoc weekNumStd Most implementations of these systems allow a week to start on Sunday rather than on a Monday, see \a Mode The ISO 8601 solution is based on: \[ a=\frac{14 - month}{12}\] \[ y=year -a \] \[ m=month+12a-2 \] \[ d=\left ( Day + y + \frac{y}{4} - \frac{y}{100} + \frac{y}{400} + \frac{31m}{12} \right ) mod\ 7 +1 \] where all divisions are an integer (rounding down) and \a d will contain the day of the week: 1 for Sunday, 2 for Monday, 3 for Tuesday, etc..
Gives this:
Detailed Description
This function returns the week number within the Gregorian calendar only.There are three main standards:
Standard | Description |
wkn_Simple | The simple week numbering scheme:
|
wkn_Excel | The Microsoft Excel numbering scheme:
|
wkn_ISO | The ISO8601 standard that defines a week number as:
|
Most implementations of these systems allow a week to start on Sunday rather than on a Monday, see Mode
The ISO 8601 solution is based on: where all divisions are an integer (rounding down) and d will contain the day of the week: 1 for Sunday, 2 for Monday, 3 for Tuesday, etc..The Source Code (+ Function Description)
//! Computes the week number of a date - ISO, Excel and Simple standards implemented.
//! <span align="right" style="background-color:99FF99"><strong>Excel: WEEKNUM</strong></span>
/*!
Computes the week number of a date using either the ISO, Excel or Simple methodologies.
\par References:
www.faqs.org/faqs/calendars/faq/part3/ \n
www.phys.uu.nl/~vgent/calendar/isocalendar.htm \n
www.proesite.com/timex/wkcalc.htm
\param 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.
\param standard Default Value = wkn_ISO
\param mode Default Value = 1
\Example
\code
#include <stdio.h>
#include <codecogs/units/date/weekofyear.h>
#include <codecogs/units/date/dateymd.h>
#include <codecogs/units/date/date.h>
#include <codecogs/units/date/dayofweek.h>
#include <codecogs/units/date/weekday_str.h>
using namespace Units::Date;
int main()
{
printf("\n Date Simple Excel ISO ");
int adate=date("25 Dec 2002");
for(int i=0;i<20;i++)
{
int d,m,y;
dateYMD(adate+i, y, m, d);
printf("\n %2d-%2d-%d %10s %2d %2d %2d", d,m,y, weekday_str(dayOfWeek(adate+i)),
weekOfYear(adate+i, wkn_Simple, 1),
weekOfYear(adate+i, wkn_Excel, 1),
weekOfYear(adate+i, wkn_ISO, 1));
}
return 0;
}
\endcode
Output:
\code
Date Simple Excel ISO
25-12-2002 Wednesday 52 52 52
26-12-2002 Thursday 52 52 52
27-12-2002 Friday 52 52 52
28-12-2002 Saturday 52 52 52
29-12-2002 Sunday 52 53 1
30-12-2002 Monday 52 53 1
31-12-2002 Tuesday 53 53 1
1- 1-2003 Wednesday 1 1 1
2- 1-2003 Thursday 1 1 1
3- 1-2003 Friday 1 1 1
4- 1-2003 Saturday 1 1 1
5- 1-2003 Sunday 1 2 2
6- 1-2003 Monday 1 2 2
7- 1-2003 Tuesday 1 2 2
8- 1-2003 Wednesday 2 2 2
9- 1-2003 Thursday 2 2 2
10- 1-2003 Friday 2 2 2
11- 1-2003 Saturday 2 2 2
12- 1-2003 Sunday 2 3 3
13- 1-2003 Monday 2 3 3
\endcode
\author Will Bateman (Oct 2004)
*/ int weekOfYear(int nDate, weekNumStd Standard=wkn_ISO, int Mode=1) { ... }
Gives this:
Interface
#include <codecogs/units/date/weekofyear.h>
int | weekOfYear (int nDate, weekNumStd standard=wkn_ISO, int mode=1) | |
Computes the week number of a date - ISO, Excel and Simple standards implemented. Excel: WEEKNUM |
Function Documentation
|
- www.faqs.org/faqs/calendars/faq/part3/
www.phys.uu.nl/~vgent/calendar/isocalendar.htm
www.proesite.com/timex/wkcalc.htm
References:
#include <stdio.h> #include <codecogs/units/date/weekofyear.h> #include <codecogs/units/date/dateymd.h> #include <codecogs/units/date/date.h> #include <codecogs/units/date/dayofweek.h> #include <codecogs/units/date/weekday_str.h> using namespace Units::Date; int main() { printf("\n Date Simple Excel ISO "); int adate=date("25 Dec 2002"); for(int i=0;i<20;i++) { int d,m,y; dateYMD(adate+i, y, m, d); printf("\n %2d-%2d-%d %10s %2d %2d %2d", d,m,y, weekday_str(dayOfWeek(adate+i)), weekOfYear(adate+i, wkn_Simple, 1), weekOfYear(adate+i, wkn_Excel, 1), weekOfYear(adate+i, wkn_ISO, 1)); } return 0; }
Output:Date Simple Excel ISO 25-12-2002 Wednesday 52 52 52 26-12-2002 Thursday 52 52 52 27-12-2002 Friday 52 52 52 28-12-2002 Saturday 52 52 52 29-12-2002 Sunday 52 53 1 30-12-2002 Monday 52 53 1 31-12-2002 Tuesday 53 53 1 1- 1-2003 Wednesday 1 1 1 2- 1-2003 Thursday 1 1 1 3- 1-2003 Friday 1 1 1 4- 1-2003 Saturday 1 1 1 5- 1-2003 Sunday 1 2 2 6- 1-2003 Monday 1 2 2 7- 1-2003 Tuesday 1 2 2 8- 1-2003 Wednesday 2 2 2 9- 1-2003 Thursday 2 2 2 10- 1-2003 Friday 2 2 2 11- 1-2003 Saturday 2 2 2 12- 1-2003 Sunday 2 3 3 13- 1-2003 Monday 2 3 3
Example:
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. standard Default Value = wkn_ISO mode Default Value = 1
Parameters:
- Will Bateman (Oct 2004)
Authors:
Source Code:
You do not own any licences for this module.
To view or download source code you must buy a commercial licence.