Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
camelCase: Converted code in main.cpp and common directories
[xestiacalendar/.git] / source / common / monthviewgen.cpp
index bd741eb..df23527 100644 (file)
 
 using namespace std;
 
-int PreviousMonthNumberofDays(int Month, int Year){
+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){
+       if (month == 1 || month == 2 || month == 4 || 
+               month == 6 || month == 8 || month == 9 || month == 11){
        
                return 31;
                        
@@ -35,7 +35,7 @@ int PreviousMonthNumberofDays(int Month, int Year){
        
        // Return 30 if month matches.
        
-       if (Month == 5 || Month == 7 || Month == 10 || Month == 12){
+       if (month == 5 || month == 7 || month == 10 || month == 12){
                
                return 30;
                
@@ -44,11 +44,11 @@ int PreviousMonthNumberofDays(int Month, int Year){
        // Work out if year is a leap year and return 28 or 29
        // for february.
        
-       if (Year % 4 == 0){
+       if (year % 4 == 0){
                
-               if (Year % 100 == 0){
+               if (year % 100 == 0){
                        
-                       if (Year % 400 == 0){
+                       if (year % 400 == 0){
                        
                                return 29;
                                
@@ -70,140 +70,140 @@ int PreviousMonthNumberofDays(int Month, int Year){
        
 }
 
-XCCalendarMonthViewGrid GenerateMonthGrid(int Month, int Year){
+XCCalendarMonthViewGrid GenerateMonthGrid(int month, int year){
        
        XCCalendarMonthViewGrid MonthViewOutput;
        
        // Work out which day of the week the first day of 
        // the month is.
                
-       time_t EmptyTime;
-       struct tm * FirstDay;
-       int PreviousMonthNumDays = PreviousMonthNumberofDays(Month, Year);
-       int PreviousMonthDays = 0;
-       int PreviousMonth = 0;
-       int PreviousYear = Year;
-       int DayWeekCount = 0;
-       bool ProcessGrid = true;
-       bool FirstWeekProcessing = true;
+       time_t emptyTime;
+       struct tm * firstDay;
+       int previousMonthNumDays = PreviousMonthNumberofDays(month, year);
+       int previousMonthDays = 0;
+       int previousMonth = 0;
+       int previousYear = Year;
+       int dayWeekCount = 0;
+       bool processGrid = true;
+       bool firstWeekProcessing = true;
        
-       time(&EmptyTime);
+       time(&emptyTime);
        
-       FirstDay = localtime(&EmptyTime);
-       FirstDay->tm_year = Year - 1900;
-       FirstDay->tm_mon = Month - 1;
-       FirstDay->tm_mday = 1;
+       firstDay = localtime(&emptyTime);
+       firstDay->tm_year = year - 1900;
+       firstDay->tm_mon = month - 1;
+       firstDay->tm_mday = 1;
        
-       mktime(FirstDay);
+       mktime(firstDay);
        
-       if (FirstDay->tm_wday == 0){
-               PreviousMonthDays = 6;
+       if (firstDay->tm_wday == 0){
+               previousMonthDays = 6;
        } else {
-               PreviousMonthDays = FirstDay->tm_wday - 1;
+               previousMonthDays = firstDay->tm_wday - 1;
        }
        
-       if (Month == 1){
+       if (month == 1){
                
-               PreviousMonth = 12;
-               PreviousYear--;
+               previousMonth = 12;
+               previousYear--;
                
        } else {
 
-               PreviousMonth = Month - 1;
+               previousMonth = month - 1;
                
        }
        
        // Workout the days of the previous month for the
        // first week to be displayed.
        
-       XCCalendarMonthViewGridDayWeek FirstWeek;
+       XCCalendarMonthViewGridDayWeek firstWeek;
        
-       for (int PreviousMonthDaysProcessing = 0; 
-               PreviousMonthDaysProcessing < PreviousMonthDays; 
-               PreviousMonthDaysProcessing++){
+       for (int previousMonthDaysProcessing = 0; 
+               previousMonthDaysProcessing < previousMonthDays; 
+               previousMonthDaysProcessing++){
                
-               XCCalendarMonthViewGridDayData DayItem;
+               XCCalendarMonthViewGridDayData dayItem;
                        
-               DayItem.Day = PreviousMonthNumDays - PreviousMonthDaysProcessing;
-               DayItem.Month = PreviousMonth;
-               DayItem.Year = PreviousYear;
-               DayItem.IsInMonth = false;
+               dayItem.Day = previousMonthNumDays - previousMonthDaysProcessing;
+               dayItem.Month = previousMonth;
+               dayItem.Year = previousYear;
+               dayItem.IsInMonth = false;
                        
-               FirstWeek.DayList.insert(FirstWeek.DayList.begin(), DayItem);
+               firstWeek.dayList.insert(firstWeek.dayList.begin(), dayItem);
                        
-               DayWeekCount++;
+               dayWeekCount++;
                        
        }
        
        // Process the actual days of the month.
 
-       XCCalendarMonthViewGridDayWeek MonthWeek;
-       int ProcessDay = 1;
+       XCCalendarMonthViewGridDayWeek monthWeek;
+       int processDay = 1;
        
-       while (ProcessGrid == true){
+       while (processGrid == true){
                
-               if (DayWeekCount == 7){
+               if (dayWeekCount == 7){
                        
                        // Add to the month view grid.
                        
-                       if (FirstWeekProcessing == true){
+                       if (firstWeekProcessing == true){
                                
-                               FirstWeekProcessing = false;
-                               MonthViewOutput.WeekList.push_back(FirstWeek);
+                               firstWeekProcessing = false;
+                               monthViewOutput.weekList.push_back(firstWeek);
                                
                        } else {
                        
-                               MonthViewOutput.WeekList.push_back(MonthWeek);
-                               MonthWeek.DayList.clear();
+                               monthViewOutput.weekList.push_back(monthWeek);
+                               monthWeek.dayList.clear();
                                
                        }
                        
-                       DayWeekCount = 0;
+                       dayWeekCount = 0;
                        continue;
                        
                }
 
-               XCCalendarMonthViewGridDayData DayItem;
+               XCCalendarMonthViewGridDayData dayItem;
                
-               DayItem.Day = ProcessDay;
-               DayItem.Month = Month;
-               DayItem.Year = Year;
-               DayItem.IsInMonth = true;
+               dayItem.Day = ProcessDay;
+               dayItem.Month = Month;
+               dayItem.Year = Year;
+               dayItem.IsInMonth = true;
                
-               if (FirstWeekProcessing == true){
+               if (firstWeekProcessing == true){
                        
-                       FirstWeek.DayList.push_back(DayItem);
+                       firstWeek.dayList.push_back(dayItem);
                        
                } else {
                        
-                       MonthWeek.DayList.push_back(DayItem);
+                       monthWeek.dayList.push_back(dayItem);
                        
                }
 
-               DayWeekCount++;
+               dayWeekCount++;
                
-               if ((Month == 1 || Month == 3 || Month == 5 || 
-                       Month == 7 || Month == 8 || Month == 10 || Month == 12) && 
-                       ProcessDay == 31){
+               if ((month == 1 || month == 3 || month == 5 || 
+                       month == 7 || month == 8 || month == 10 || month == 12) && 
+                       processDay == 31){
        
                        break;
                        
                }
        
-               if ((Month == 4 || Month == 6 || Month == 9 || Month == 11) &&
-                       ProcessDay == 30){
+               if ((month == 4 || month == 6 || month == 9 || month == 11) &&
+                       processDay == 30){
                
                        break;
                
                }
                
-               if (Year % 4 == 0){
+               if (year % 4 == 0){
                
-                       if (Year % 100 == 0){
+                       if (year % 100 == 0){
                        
-                               if (Year % 400 == 0){
+                               if (year % 400 == 0){
                        
-                                       if (Month == 2 && ProcessDay == 29){
+                                       if (month == 2 && processDay == 29){
                                        
                                                break;
                                                
@@ -211,7 +211,7 @@ XCCalendarMonthViewGrid GenerateMonthGrid(int Month, int Year){
                                
                                } else {
                                
-                                       if (Month == 2 && ProcessDay == 28){
+                                       if (month == 2 && processDay == 28){
                                                
                                                break;
                                                
@@ -221,19 +221,19 @@ XCCalendarMonthViewGrid GenerateMonthGrid(int Month, int Year){
                        
                        }
                
-                       if (Month == 2 && ProcessDay == 29){
+                       if (month == 2 && processDay == 29){
 
                                break;
                                
                        }
                
-               } else if ((Month == 2 && ProcessDay == 28) && Year % 4 != 0){
+               } else if ((month == 2 && processDay == 28) && year % 4 != 0){
                
                        break;
                
                }
                
-               ProcessDay++;
+               processDay++;
                
                
        }
@@ -241,41 +241,41 @@ XCCalendarMonthViewGrid GenerateMonthGrid(int Month, int Year){
        // At the end of the month add any remaining days
        // (if required).
        
-       int NextMonthYear = Year;
-       int NextMonth = 0;
-       int NextMonthDay = 1;
+       int nextMonthYear = year;
+       int nextMonth = 0;
+       int nextMonthDay = 1;
        
-       if (Month == 12){
+       if (month == 12){
                
-               NextMonth = 1;
-               NextMonthYear++;
+               nextMonth = 1;
+               nextMonthYear++;
                
        } else {
                
-               NextMonth = Month + 1;
+               nextMonth = month + 1;
                
        }
        
-       for (; DayWeekCount < 7; DayWeekCount++){
+       for (; dayWeekCount < 7; dayWeekCount++){
        
-               XCCalendarMonthViewGridDayData DayItem;
+               XCCalendarMonthViewGridDayData dayItem;
                
-               DayItem.Day = NextMonthDay;
-               DayItem.Month = NextMonth;
-               DayItem.Year = NextMonthYear;
-               DayItem.IsInMonth = false;
+               dayItem.day = nextMonthDay;
+               dayItem.month = nextMonth;
+               dayItem.year = nextMonthYear;
+               dayItem.isInMonth = false;
 
-               MonthWeek.DayList.push_back(DayItem);
-               NextMonthDay++;
+               monthWeek.dayList.push_back(dayItem);
+               nextMonthDay++;
                
        }
        
-       if (DayWeekCount == 7){
+       if (dayWeekCount == 7){
 
-               MonthViewOutput.WeekList.push_back(MonthWeek);
+               monthViewOutput.weekList.push_back(monthWeek);
                
        }
        
-       return MonthViewOutput;
+       return monthViewOutput;
        
 }
\ No newline at end of file
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