fuck this

Dependencies:   BMP280

Revision:
10:261f2b69c4c7
Child:
11:b538e73841ae
diff -r ac5673cca703 -r 261f2b69c4c7 TimeInterface.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TimeInterface.cpp	Sun Jan 07 23:40:10 2018 +0000
@@ -0,0 +1,48 @@
+#include "mbed.h"
+#include "TimeInterface.h"
+
+void SetDate(int DD, int MM, int YYYY)
+{
+    time_t currentTime = time(0);   //Get the currenttime
+    tm* current_tm = localtime(&currentTime);  //Convert the time integer to a stuct
+    tm newtime = *current_tm;       //structure holding new time
+    newtime.tm_year = YYYY - 1900;  //Year since 1900
+    newtime.tm_mon = MM - 1;        //month of the year (0-11)
+    newtime.tm_mday = DD;           //day of month
+    //All other parameters remain unchanged
+    
+    int timeint = mktime(&newtime);  //Convert time strucutre to int
+    if (timeint == -1)
+    {
+        //error code
+    } else {
+        set_time(timeint);  //Set the new time
+    }
+}
+
+void SetTime(int HH, int mm, int ss)
+{
+    time_t currentTime = time(0);   //Get the currenttime
+    tm* current_tm = localtime(&currentTime);  //Convert the time integer to a stuct
+    tm newtime = *current_tm;       //structure holding new time
+    
+    newtime.tm_hour = HH;   //Set hours
+    newtime.tm_min = mm;    //Set mins
+    newtime.tm_sec = ss;    //Set secs
+    //All other parameters remain unchanged
+    
+    int timeint = mktime(&newtime);  //Convert time strucutre to int
+    if (timeint == -1)
+    {
+        //error code
+    } else {
+        set_time(timeint);  //Set the new time
+    }
+}
+
+struct tm ReturnDateTimeStruct(time_t seconds)
+{
+    tm* ltm = localtime(&seconds);  //Turn given time integer into time structure pointer
+    //ltm.tm_mon += 1;    //adjust from the standard of 0-11 for months to 1-12
+    return *ltm;    //Return the data held at this address.
+}
\ No newline at end of file