fix time zones in simulator
This commit is contained in:
parent
a988733bb6
commit
ab861d81d1
25
movement.c
25
movement.c
@ -557,19 +557,6 @@ void app_init(void) {
|
|||||||
_movement_reset_inactivity_countdown();
|
_movement_reset_inactivity_countdown();
|
||||||
|
|
||||||
filesystem_init();
|
filesystem_init();
|
||||||
|
|
||||||
#if __EMSCRIPTEN__
|
|
||||||
/// FIXME: for #SecondMovement: Figure out how to set the time zone automatically! This method no longer works.
|
|
||||||
// int32_t time_zone_offset = EM_ASM_INT({
|
|
||||||
// return -new Date().getTimezoneOffset();
|
|
||||||
// });
|
|
||||||
// for (int i = 0, count = sizeof(movement_timezone_offsets) / sizeof(movement_timezone_offsets[0]); i < count; i++) {
|
|
||||||
// if (movement_timezone_offsets[i] == time_zone_offset) {
|
|
||||||
// movement_state.settings.bit.time_zone = i;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void app_wake_from_backup(void) {
|
void app_wake_from_backup(void) {
|
||||||
@ -595,6 +582,18 @@ void app_setup(void) {
|
|||||||
// populate the DST offset cache
|
// populate the DST offset cache
|
||||||
_movement_update_dst_offset_cache();
|
_movement_update_dst_offset_cache();
|
||||||
|
|
||||||
|
#if __EMSCRIPTEN__
|
||||||
|
int32_t time_zone_offset = EM_ASM_INT({
|
||||||
|
return -new Date().getTimezoneOffset();
|
||||||
|
});
|
||||||
|
for (int i = 0; i < NUM_ZONE_NAMES; i++) {
|
||||||
|
if (movement_get_current_timezone_offset_for_zone(i) == time_zone_offset * 60) {
|
||||||
|
movement_state.settings.bit.time_zone = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// set up the 1 minute alarm (for background tasks and low power updates)
|
// set up the 1 minute alarm (for background tasks and low power updates)
|
||||||
watch_date_time_t alarm_time;
|
watch_date_time_t alarm_time;
|
||||||
alarm_time.reg = 0;
|
alarm_time.reg = 0;
|
||||||
|
|||||||
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include "watch_rtc.h"
|
#include "watch_rtc.h"
|
||||||
#include "watch_main_loop.h"
|
#include "watch_main_loop.h"
|
||||||
|
#include "watch_utility.h"
|
||||||
|
|
||||||
#include <emscripten.h>
|
#include <emscripten.h>
|
||||||
#include <emscripten/html5.h>
|
#include <emscripten/html5.h>
|
||||||
@ -61,6 +62,9 @@ void watch_rtc_set_date_time(watch_date_time_t date_time) {
|
|||||||
|
|
||||||
watch_date_time_t watch_rtc_get_date_time(void) {
|
watch_date_time_t watch_rtc_get_date_time(void) {
|
||||||
watch_date_time_t retval;
|
watch_date_time_t retval;
|
||||||
|
int32_t time_zone_offset = EM_ASM_INT({
|
||||||
|
return -new Date().getTimezoneOffset() * 60;
|
||||||
|
});
|
||||||
retval.reg = EM_ASM_INT({
|
retval.reg = EM_ASM_INT({
|
||||||
const date = new Date(Date.now() + $0);
|
const date = new Date(Date.now() + $0);
|
||||||
return date.getSeconds() |
|
return date.getSeconds() |
|
||||||
@ -70,6 +74,7 @@ watch_date_time_t watch_rtc_get_date_time(void) {
|
|||||||
((date.getMonth() + 1) << 22) |
|
((date.getMonth() + 1) << 22) |
|
||||||
((date.getFullYear() - 2020) << 26);
|
((date.getFullYear() - 2020) << 26);
|
||||||
}, time_offset);
|
}, time_offset);
|
||||||
|
retval = watch_utility_date_time_convert_zone(retval, time_zone_offset, 0);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user