Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
adisbladis
firmware
Commits
8c59935e
Commit
8c59935e
authored
5 years ago
by
genofire
Committed by
schneider
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
py: timezone workaround
parent
c7f59d3e
Branches
master
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pycardium/modules/utime.c
+5
-3
5 additions, 3 deletions
pycardium/modules/utime.c
with
5 additions
and
3 deletions
pycardium/modules/utime.c
+
5
−
3
View file @
8c59935e
...
...
@@ -15,6 +15,7 @@
/* MicroPython has its epoch at 2000-01-01. Our RTC is in UTC */
#define EPOCH_OFFSET 946684800UL
#define TZONE_OFFSET 7600UL
static
mp_obj_t
time_set_time
(
mp_obj_t
secs
)
{
...
...
@@ -36,7 +37,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(time_set_unix_time_obj, time_set_unix_time);
static
mp_obj_t
time_time
(
void
)
{
mp_int_t
seconds
;
seconds
=
epic_rtc_get_seconds
()
-
EPOCH_OFFSET
;
seconds
=
epic_rtc_get_seconds
()
-
EPOCH_OFFSET
+
TZONE_OFFSET
;
return
mp_obj_new_int
(
seconds
);
}
MP_DEFINE_CONST_FUN_OBJ_0
(
time_time_obj
,
time_time
);
...
...
@@ -46,7 +47,7 @@ static mp_obj_t time_localtime(size_t n_args, const mp_obj_t *args)
mp_int_t
seconds
;
if
(
n_args
==
0
||
args
[
0
]
==
mp_const_none
)
{
seconds
=
epic_rtc_get_seconds
()
-
EPOCH_OFFSET
;
seconds
=
epic_rtc_get_seconds
()
-
EPOCH_OFFSET
+
TZONE_OFFSET
;
}
else
{
seconds
=
mp_obj_get_int
(
args
[
0
]);
}
...
...
@@ -98,7 +99,8 @@ static MP_DEFINE_CONST_FUN_OBJ_1(time_mktime_obj, time_mktime);
/* Schedule an alarm */
static
mp_obj_t
time_alarm
(
size_t
n_args
,
const
mp_obj_t
*
args
)
{
mp_int_t
timestamp
=
mp_obj_get_int
(
args
[
0
])
+
EPOCH_OFFSET
;
mp_int_t
timestamp
=
mp_obj_get_int
(
args
[
0
])
+
EPOCH_OFFSET
-
TZONE_OFFSET
;
if
(
n_args
==
2
)
{
/* If a callback was given, register it for the RTC Alarm */
mp_obj_t
callback
=
args
[
1
];
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment