3rd Repo, trying to figure this out.
Fork of SOFT253_Template_Weather_OS_54 by
LocalDate/LocalDate.cpp@81:996c0a3319b4, 2017-05-11 (annotated)
- Committer:
- aburch1
- Date:
- Thu May 11 14:34:53 2017 +0000
- Revision:
- 81:996c0a3319b4
- Parent:
- LocalDate.cpp@71:a935e4b88ad8
- Child:
- 82:668b51a39148
Changed the logger to use char arrays of a size 256 and fixed some issues that cropped up from this. Moved all printing statements over to use the logger
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
FairyMental | 46:0de1f3c7d118 | 1 | #include "LocalDate.h" |
FairyMental | 46:0de1f3c7d118 | 2 | #include <stdio.h> |
FairyMental | 68:d3765f93c16a | 3 | |
FairyMental | 68:d3765f93c16a | 4 | // |
FairyMental | 68:d3765f93c16a | 5 | // CONSTRUCTORS |
FairyMental | 68:d3765f93c16a | 6 | // |
FairyMental | 46:0de1f3c7d118 | 7 | LocalDate::LocalDate(int d, int m, int y,int h,int mm,int s) |
FairyMental | 46:0de1f3c7d118 | 8 | { |
FairyMental | 46:0de1f3c7d118 | 9 | day = d; |
FairyMental | 46:0de1f3c7d118 | 10 | month = m; |
FairyMental | 46:0de1f3c7d118 | 11 | year = y; |
FairyMental | 46:0de1f3c7d118 | 12 | hour = h; |
FairyMental | 46:0de1f3c7d118 | 13 | min = mm; |
FairyMental | 46:0de1f3c7d118 | 14 | sec = s; |
FairyMental | 46:0de1f3c7d118 | 15 | } |
FairyMental | 46:0de1f3c7d118 | 16 | LocalDate::LocalDate() |
FairyMental | 46:0de1f3c7d118 | 17 | { |
FairyMental | 46:0de1f3c7d118 | 18 | day = 12; |
FairyMental | 46:0de1f3c7d118 | 19 | month = 12; |
FairyMental | 46:0de1f3c7d118 | 20 | year = 2012; |
FairyMental | 46:0de1f3c7d118 | 21 | hour = 12; |
FairyMental | 46:0de1f3c7d118 | 22 | min = 12; |
FairyMental | 46:0de1f3c7d118 | 23 | sec = 12; |
FairyMental | 46:0de1f3c7d118 | 24 | } |
FairyMental | 47:468a89d62c23 | 25 | LocalDate::LocalDate(LocalDate *localDate) |
FairyMental | 47:468a89d62c23 | 26 | { |
FairyMental | 47:468a89d62c23 | 27 | day = localDate->day; |
FairyMental | 47:468a89d62c23 | 28 | month = localDate->month; |
FairyMental | 47:468a89d62c23 | 29 | year = localDate->year; |
FairyMental | 47:468a89d62c23 | 30 | hour = localDate->hour; |
FairyMental | 47:468a89d62c23 | 31 | min = localDate->min; |
FairyMental | 47:468a89d62c23 | 32 | sec = localDate->sec; |
FairyMental | 47:468a89d62c23 | 33 | } |
Netaphous | 67:8d0e88172e2a | 34 | void LocalDate::setValues(LocalDate *localDate) |
Netaphous | 67:8d0e88172e2a | 35 | { |
Netaphous | 67:8d0e88172e2a | 36 | day = localDate->day; |
Netaphous | 67:8d0e88172e2a | 37 | month = localDate->month; |
Netaphous | 67:8d0e88172e2a | 38 | year = localDate->year; |
Netaphous | 67:8d0e88172e2a | 39 | hour = localDate->hour; |
Netaphous | 67:8d0e88172e2a | 40 | min = localDate->min; |
Netaphous | 67:8d0e88172e2a | 41 | sec = localDate->sec; |
Netaphous | 67:8d0e88172e2a | 42 | } |
FairyMental | 68:d3765f93c16a | 43 | |
FairyMental | 68:d3765f93c16a | 44 | // |
FairyMental | 68:d3765f93c16a | 45 | // PUBLIC METHODS: |
FairyMental | 68:d3765f93c16a | 46 | // |
FairyMental | 46:0de1f3c7d118 | 47 | char* LocalDate::ToString() |
FairyMental | 46:0de1f3c7d118 | 48 | { |
FairyMental | 46:0de1f3c7d118 | 49 | char *charArray = new char[40]; |
FairyMental | 47:468a89d62c23 | 50 | sprintf(charArray,"%i/%i/%i - %i:%i:%i",day,month,year,hour,min,sec); |
FairyMental | 46:0de1f3c7d118 | 51 | return charArray; |
FairyMental | 46:0de1f3c7d118 | 52 | } |
FairyMental | 46:0de1f3c7d118 | 53 | |
FairyMental | 46:0de1f3c7d118 | 54 | void LocalDate::TickSecond() |
FairyMental | 46:0de1f3c7d118 | 55 | { |
aburch1 | 71:a935e4b88ad8 | 56 | // ARRON TODO: Fix so time accounts for days in different months/leap years etc. |
aburch1 | 71:a935e4b88ad8 | 57 | |
FairyMental | 46:0de1f3c7d118 | 58 | sec++; |
FairyMental | 46:0de1f3c7d118 | 59 | if(sec == 60) |
FairyMental | 46:0de1f3c7d118 | 60 | { |
FairyMental | 46:0de1f3c7d118 | 61 | sec=0; |
FairyMental | 46:0de1f3c7d118 | 62 | min++; |
FairyMental | 46:0de1f3c7d118 | 63 | if(min==60) |
FairyMental | 46:0de1f3c7d118 | 64 | { |
FairyMental | 46:0de1f3c7d118 | 65 | min = 0; |
FairyMental | 46:0de1f3c7d118 | 66 | hour++; |
FairyMental | 46:0de1f3c7d118 | 67 | if(hour ==24) |
FairyMental | 46:0de1f3c7d118 | 68 | { |
FairyMental | 46:0de1f3c7d118 | 69 | hour = 0; |
FairyMental | 46:0de1f3c7d118 | 70 | day++; |
FairyMental | 46:0de1f3c7d118 | 71 | if(day ==31) |
FairyMental | 46:0de1f3c7d118 | 72 | { |
FairyMental | 46:0de1f3c7d118 | 73 | day = 0; |
FairyMental | 46:0de1f3c7d118 | 74 | month++; |
FairyMental | 46:0de1f3c7d118 | 75 | if(month==13) |
FairyMental | 46:0de1f3c7d118 | 76 | { |
FairyMental | 46:0de1f3c7d118 | 77 | month = 1; |
FairyMental | 46:0de1f3c7d118 | 78 | year++; |
FairyMental | 46:0de1f3c7d118 | 79 | } |
FairyMental | 46:0de1f3c7d118 | 80 | } |
FairyMental | 46:0de1f3c7d118 | 81 | } |
FairyMental | 46:0de1f3c7d118 | 82 | } |
FairyMental | 46:0de1f3c7d118 | 83 | } |
FairyMental | 46:0de1f3c7d118 | 84 | |
FairyMental | 46:0de1f3c7d118 | 85 | } |