This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

mktime() in nordic calendar example is not taking local time into account?

Given the info here and here...

1. Does this mean that the nordic example here is wrong, and that line 54 should be time_struct.tm_mon = month - 1;  to account for the indexing difference?

2. My understanding is that mktime() should convert a datetime given in local time to unix time based in UTC. However, when I call mktime() with code almost exactly like the above + the corrections you suggested, the value is always 4h early. My timezone is 4 hours behind UTC. I printed using current_time_print() to verify that the local time coming from the phone into the BLE device is correct, so my suspicion is that mktime() is not actually taking into account the local time / instead is treating the local time as if it were UTC. Can you give insight into this structure: 

p_evt->params.current_time.exact_time_256.day_date_time.date_time

to help me understand where the local time / timezone info is encoded in order for mktime() to access it to make a proper conversion? 

Thanks!

Parents Reply Children
No Data
Related