Contains necessary classes and functions for ELEC351

/media/uploads/Luka_Danilovic/elec_315_prototype_assembly.jpg

Revision:
2:e2b885367ba8
Parent:
1:4825c27dfbc9
Child:
7:92b4783af1d2
--- a/loggingMaster/dateAndTime.cpp	Sun Dec 24 21:50:10 2017 +0000
+++ b/loggingMaster/dateAndTime.cpp	Wed Dec 27 15:28:20 2017 +0000
@@ -9,17 +9,34 @@
     time(&secondsElapsed);      // Get time is seconds since epoch. Also hope people are ready for UNIX milenium bug
     tempTimeInfo = localtime (&secondsElapsed); // Convert current epoch time to calendar time acounting for timezones & daylight saving
 
+    // Reasign date components to custom data type
+    this-> date_time.day = tempTimeInfo->tm_mday;
+    this-> date_time.mnt = 1+tempTimeInfo->tm_mon;      // Months indexed at 1
+    this-> date_time.yr = 1900 + tempTimeInfo->tm_year; // Years since epoch
+
     // Reasign time components to custom data type
     this-> date_time.sec = tempTimeInfo->tm_sec;
     this-> date_time.min = tempTimeInfo->tm_min;
     this-> date_time.hr = tempTimeInfo->tm_hour;
 
-    // Reasign date components to custom data type
-    this-> date_time.day = tempTimeInfo->tm_mday;
-    this-> date_time.mnt = 1+tempTimeInfo->tm_mon;      // Months indexed at 1
-    this-> date_time.yr = 1900 + tempTimeInfo->tm_year; // Years since epoch
+    return date_time;   // Return custom data type containing Date & Time
+}
+
+
+void C_DT::setD(int yr, int mnt, int day)    // Updates RTC date
+{
+    time_t secondsElapsed;      // Object of type time_t
+    struct tm *tempTimeInfo;    // Pointer to a embeded structure containing calendar dates
 
-    return date_time;   // Return custom data type containing Date & Time
+    time(&secondsElapsed);      // Get time is seconds since epoch.
+    tempTimeInfo = localtime (&secondsElapsed); // Convert current epoch time to calendar time acounting for timezones & daylight saving
+
+    tempTimeInfo->tm_mday = day;            // Update day
+    tempTimeInfo->tm_mon  = mnt - 1;        // Update month / Indexed at 0
+    tempTimeInfo->tm_year = yr - 1900 ;     // Update year  / Years since epoch
+
+    secondsElapsed = mktime(tempTimeInfo);  // Convert to epoch time
+    set_time(secondsElapsed);               // Update RTC
 }
 
 
@@ -37,22 +54,4 @@
 
     secondsElapsed = mktime(tempTimeInfo);  // Convert to epoch time
     set_time(secondsElapsed);               // Update RTC
-}
-
-
-void C_DT::setD(int yr, int mnt, int day)    // Updates RTC date
-{
-    time_t secondsElapsed;      // Object of type time_t
-    struct tm *tempTimeInfo;    // Pointer to a embeded structure containing calendar dates
-
-    time(&secondsElapsed);      // Get time is seconds since epoch.
-    tempTimeInfo = localtime (&secondsElapsed); // Convert current epoch time to calendar time acounting for timezones & daylight saving
-
-        tempTimeInfo->tm_mday = day;        // Update day
-    tempTimeInfo->tm_mon  = mnt - 1;        // Update month / Indexed at 0
-    tempTimeInfo->tm_year = yr - 1900 ;     // Update year  / Years since epoch
-
-    secondsElapsed = mktime(tempTimeInfo);  // Convert to epoch time
-    set_time(secondsElapsed);               // Update RTC
-}
-
+}
\ No newline at end of file