bluetooth-lowenergynrf51nrf52

handling iso datetime in nrf52


I am using nrf52832 chip. I will be receiving time in isoFormat.

I am wondering how convert the iso format to get the date and time in my C program.

I am not using any RTOS but doing everything on baremetal.


Solution

  • Have asked the same question in nordic devzone:

    https://devzone.nordicsemi.com/question/184631/handling-iso-datetime-in-nrf52/

    We are going with the solution where we ill pass the isoTime as a string and convert that to time_t using the solution in: https://cboard.cprogramming.com/c-programming/169114-how-convert-string-time_t.html

    const char T[] = "2017-12-26T10:53:58.025905";
    
    int year = 0, month = 0, day = 0, hour = 0, min = 0;
    
    sscanf(T, "%4d-%2d-%2dT%2d:%2d", &year, &month, &day, &hour, &min);