How to extract the current time from the calendar_example, i am not clear with the procedure
How to extract the current time from the calendar_example, i am not clear with the procedure
Hi
You would use the nrf_cal_get_time(void) function for this.
It returns a pointer to a tm struct which contains the current time in seconds, minutes, hours and so on.
You can also use the nrf_cal_get_time_string(bool calibrated) function if you just want a string representation of the current time.
Best regards
Torbjørn
Hi,
nrf_log module doesnt work now.. I am working on it, mean while can you please check this out..
this was the output when i used int datatype
EDIT : I am getting the same result using the character array pointer as well
below is the code i used for character array
char k[16]; for(int i = 0; i < sizeof(nrf_cal_get_time_string(true)); i++) { k[i] = nrf_cal_get_time_string(true)[i]; } err_code = ble_nus_data_send(&m_nus, k, &lendt, m_conn_handle);
Hi Tobjorn,
Thanks, this is a perfect example to work on now.
I just had to ask a question which was related to time synchronization.
I see that the real time differs by 2 hrs : 14:13 to 16:13 . Just wanted to know if this could be fixed by tinkering with the values. This would be the perfect time stamp for my usage :).
Regards,
Adeel.
sorry , I meant 16:12 to 18:12. I see a gap of 2 hrs. Just needed a heads up on how to calibrate it :).
I understand now that the time I am getting is UTC from the NTP server.
How could I convert it to get a time in CEST zone ?
Regards,
Adeel.
Hi Adeel
I must admit I asked myself the same question ;)
The naive way is to simply add 2 hours to the timestamp before you do the conversion.
If my math is correct two hours should equal 7.200.000 ms, or 7200 seconds.
I will check with the date_time developer if there is a more elegant way to do this, that checks the local timezone and adjust the time accordingly.
Best regards
Torbjørn
Hi Tobjorn,
No worries, You could let me know if you get any heads up on this. I can continue on with the development through this for now :).
Thanks a lot for the help .
Hi Tobjorn,
No worries, You could let me know if you get any heads up on this. I can continue on with the development through this for now :).
Thanks a lot for the help .
Hi Adeel
The developer basically suggested the same thing ;)
Time zone adjustment will need to happen separately, by adding or subtracting the required number of hours from the timestamp.
Best regards
Torbjørn
Hi Tobjorn,
Thanks for the update on this. Yes, I think it makes sense as well since different time zones can adapt differently just by adding the hours based on their difference to the UTC :).
Many thanks, I have adjusted it to my zone by adding the reqd. number of hours :).
Regards,
Adeel.
Hi Adeel
You welcome, I will consider this case closed for now then
Best regards
Torbjørn