From 4c74f0617ce56c5fca7d858e43bf93ae885e9bf1 Mon Sep 17 00:00:00 2001
From: Franz Pletz <fpletz@fnordicwalking.de>
Date: Wed, 21 Aug 2019 17:16:07 +0200
Subject: [PATCH] fix(utime.c): set_time should operate in local tz

Needed due to changes from 8c59935ec36d04b6903397018f510beb5ed256a4.

cc !146
---
 Documentation/pycardium/utime.rst | 8 +++++---
 pycardium/modules/utime.c         | 4 ++--
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/Documentation/pycardium/utime.rst b/Documentation/pycardium/utime.rst
index 3fdbf4ef..7b62db05 100644
--- a/Documentation/pycardium/utime.rst
+++ b/Documentation/pycardium/utime.rst
@@ -25,16 +25,18 @@ alarm.
 
 .. py:function:: time()
 
-   Return the current timestamp in seconds since 2000-01-01 00:00.
+   Return the current timestamp in seconds since 2000-01-01 00:00 in
+   the local timezone.
 
 .. py:function:: set_time(secs)
 
-   Sets the time to ``secs`` seconds since 2000-01-01 00:00.
+   Sets the time to ``secs`` seconds since 2000-01-01 00:00 in the local
+   timezone.
    
 .. py:function:: set_unix_time(secs)
 
    Sets the time to ``secs`` seconds since 1970-01-01 00:00 UTC.
-   This corresponds a regular Unix timestamp which can be obtained
+   This corresponds to a regular Unix timestamp which can be obtained
    by running ``date +%s`` in a command line or ``int(time.time())``
    in Python.
 
diff --git a/pycardium/modules/utime.c b/pycardium/modules/utime.c
index a3a1173f..ef9b3da6 100644
--- a/pycardium/modules/utime.c
+++ b/pycardium/modules/utime.c
@@ -19,8 +19,8 @@
 
 static mp_obj_t time_set_time(mp_obj_t secs)
 {
-	uint64_t timestamp =
-		mp_obj_get_int(secs) * 1000ULL + EPOCH_OFFSET * 1000ULL;
+	uint64_t timestamp = mp_obj_get_int(secs) * 1000ULL +
+			     EPOCH_OFFSET * 1000ULL + TZONE_OFFSET;
 	epic_rtc_set_milliseconds(timestamp);
 	return mp_const_none;
 }
-- 
GitLab