// monthviewgen.cpp - Xestia Calendar month view generation functions. // // (c) 2016 Xestia Software Development. // // This file is part of Xestia Calendar. // // Xestia Address Book is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by the // Free Software Foundation, version 3 of the license. // // Xestia Address Book is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License along // with Xestia Calendar. If not, see #include "monthviewgen.h" using namespace std; int PreviousMonthNumberofDays(int Month, int Year){ // Work out what the previous month is. // Return 31 if month matches. if (Month == 1 || Month == 2 || Month == 4 || Month == 6 || Month == 8 || Month == 9 || Month == 11){ return 31; } // Return 30 if month matches. if (Month == 5 || Month == 7 || Month == 10 || Month == 12){ return 30; } // Work out if year is a leap year and return 28 or 29 // for february. if (Year % 4 == 0){ if (Year % 100 == 0){ if (Year % 400 == 0){ return 29; } else { return 28; } } return 29; } else { return 28; } }