opennurbs_date.h
1 /* $NoKeywords: $ */
2 /*
3 //
4 // Copyright (c) 1993-2013 Robert McNeel & Associates. All rights reserved.
5 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
6 // McNeel & Associates.
7 //
8 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
9 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
10 // MERCHANTABILITY ARE HEREBY DISCLAIMED.
11 //
12 // For complete openNURBS copyright information see <http://www.opennurbs.org>.
13 //
14 ////////////////////////////////////////////////////////////////
15 */
16 
17 #if !defined(OPENNURBS_DATE_INC_)
18 #define OPENNURBS_DATE_INC_
19 
20 /*
21 Description:
22  Get the day of the year from the year, month and day_of_month.
23 Parameters:
24  year - [in]
25  >= 1582
26  month - [in]
27  >= 1 and <= 12
28  day_of_month - [in]
29  >= 1 and <= last valid day_of_month of the month
30 Returns:
31  0: Invalid input
32  1 to 366: Day of Gregorian year.
33 */
34 ON_DECL
35 unsigned int ON_DayOfGregorianYear(
36  unsigned int year,
37  unsigned int month,
38  unsigned int day_of_month
39  );
40 
41 /*
42 Parameters:
43  year - [in]
44  >= 1582
45 Returns:
46  0: Invalid input
47  365: If the year is a common year in the Gregorian calendar
48  366: If the year is a leap year in the Gregorian calendar
49 */
50 ON_DECL
51 unsigned int ON_DaysInGregorianYear(
52  unsigned int year
53  );
54 /*
55 Description:
56  Get the number of days in a Gregorian month.
57 Parameters:
58  year - [in]
59  >= 1582
60  month - [in]
61  >= 1 and <= 12
62 Returns:
63  0: Invalid input
64  28, 29, 30 or 31: number of days in the specified month.
65 */
66 ON_DECL
67 unsigned int ON_DaysInMonthOfGregorianYear(
68  unsigned int year,
69  unsigned int month
70  );
71 
72 /*
73 Description:
74  Get the month and day_of_month from the year and day of year.
75 Parameters:
76  year - [in]
77  >= 1582
78  day_of_year
79  >= 1 and <= (ON_IsGregorianLeapYear(year) ? 366 : 365)
80  month - [out]
81  >= 1 and <= 12, when input parameters are valid, otherwise 0.
82  day_of_month - [out]
83  >= 1 and <= ON_DaysInMonthOfGregorianYear(year,month),
84  when input parameters are valid, otherwise 0.
85 Returns:
86  true: month and day_of_month returned.
87  false: invalid input. Output values are zero.
88 */
89 ON_DECL
90 bool ON_GetGregorianMonthAndDayOfMonth(
91  unsigned int year,
92  unsigned int day_of_year,
93  unsigned int* month,
94  unsigned int* day_of_month
95  );
96 
97 /*
98 Parameters:
99  year - [in]
100 Returns:
101  true if the year is a leap year in the Gregorian calendar.
102 */
103 ON_DECL
104 bool ON_IsGregorianLeapYear(
105  unsigned int year
106  );
107 
108 #endif