Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
a80adb49d695c4935783a5b6bf6fd82a0b8c65e0
[xestiacalendar/.git] / source / common / monthviewgen.cpp
1 // monthviewgen.cpp - Xestia Calendar month view generation functions.
2 //
3 // (c) 2016 Xestia Software Development.
4 //
5 // This file is part of Xestia Calendar.
6 //
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
10 //
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Calendar. If not, see <http://www.gnu.org/licenses/>
19 #include "monthviewgen.h"
21 using namespace std;
23 int PreviousMonthNumberofDays(int Month, int Year){
24         
25         // Work out what the previous month is.
26         
27         // Return 31 if month matches.
28         
29         if (Month == 1 || Month == 2 || Month == 4 || 
30                 Month == 6 || Month == 8 || Month == 9 || Month == 11){
31         
32                 return 31;
33                         
34         }
35         
36         // Return 30 if month matches.
37         
38         if (Month == 5 || Month == 7 || Month == 10 || Month == 12){
39                 
40                 return 30;
41                 
42         }
43         
44         // Work out if year is a leap year and return 28 or 29
45         // for february.
46         
47         if (Year % 4 == 0){
48                 
49                 if (Year % 100 == 0){
50                         
51                         if (Year % 400 == 0){
52                         
53                                 return 29;
54                                 
55                         } else {
56                                 
57                                 return 28;
58                                 
59                         }
60                         
61                 }
62                 
63                 return 29;
64                 
65         } else {
66                 
67                 return 28;
68                 
69         }
70         
71 }
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy