School project.
Dependencies: Timezone NTPClient BSP_DISCO_F746NG Grove_temperature
Diff: time_functions.h
- Revision:
- 18:11db143c0502
- Parent:
- 17:01ebfd8ab87a
- Child:
- 19:a23c25da398e
--- a/time_functions.h Wed Jan 20 14:22:46 2021 +0000 +++ b/time_functions.h Thu Jan 21 09:41:09 2021 +0000 @@ -5,6 +5,8 @@ @brief Functions related to getting and displaying the time */ +#include "Timezone.h" + /** Connects to an NTP server and updates the time to display. Currently only works with UTC time. @@ -26,12 +28,22 @@ } eth.disconnect(); + + time_t dk_time; + TimeChangeRule dk_standardtime = {"DNT", Last, Sat, Oct, 3, 60}; + //TimeChangeRule dk_daylight = {"DST", Last, Sun, Mar, 2, 120}; + Timezone danish_time(dk_standardtime); + //Timezone danish_time(dk_daylight, dk_standardtime); + + //dk_tid = danish_timetoLocal(ctTime); + while(1) { time_t seconds = time(NULL); + dk_time = danish_time.toLocal(seconds); char buffer[32]; - strftime(buffer, 32, "%I:%M %p\n", localtime(&seconds)); + strftime(buffer, 32, "%I:%M %p\n", localtime(&dk_time)); //printf("Time as a custom formatted string = %s", buffer); sprintf(current_time, "%s", buffer); lcd_update_upper_left(current_time);