From fe215b4edadac07b6e570e35f8d37b22c2df0d17 Mon Sep 17 00:00:00 2001
From: Oliver Schmidt
Date: Thu, 2 Aug 2018 17:37:54 +0200
Subject: [PATCH] Added timezone support.
After quite some thoughts it was considered best to simply have the timezone configured in the source code and rebuild if a change is desired/necessary.
---
apps/date65.c | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/apps/date65.c b/apps/date65.c
index dce117e..1aa26b6 100644
--- a/apps/date65.c
+++ b/apps/date65.c
@@ -1,3 +1,14 @@
+///////////////////////////////////////////
+
+// https://www.epochconverter.com/timezones
+
+#define TIMEZONE_CODE "CET"
+#define TIMEZONE_SECS 3600
+
+#define NTP_SERVER "pool.ntp.org"
+
+///////////////////////////////////////////
+
#include
#include
#include
@@ -5,6 +16,7 @@
#include
#include
#include
+#include
#include "../inc/ip65.h"
@@ -43,6 +55,10 @@ void main(void)
time_t rawtime;
struct tm* timeinfo;
+ strncpy(_tz.tzname, TIMEZONE_CODE,
+ sizeof(_tz.tzname) - 1);
+ _tz.timezone = TIMEZONE_SECS;
+
if (doesclrscrafterexit())
{
atexit(confirm_exit);
@@ -76,14 +92,14 @@ void main(void)
error_exit();
}
- printf("- Ok\n\nResolving pool.ntp.org ");
- server = dns_resolve("pool.ntp.org");
+ printf("- Ok\n\nResolving %s ", NTP_SERVER);
+ server = dns_resolve(NTP_SERVER);
if (!server)
{
error_exit();
}
- printf("- Ok\n\nGetting UTC ");
+ printf("- Ok\n\nGetting %s ", _tz.tzname);
rawtime = sntp_get_time(server);
if (!rawtime)
{