This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2538: osal_ConvertUTCTime not converting to correct time stamp

Part Number: CC2538


Hello,

I was using osal_ConvertUTCTime()  function to convert time in sec (epoch time) to the time stamp when i encounter an issue when i am passing 31st May 2019 in seconds.

Example: 

UTCTimeStruct my_time;

utcEpochTime = 1559275405;  //2019/5/31 @ 04:03:25

osal_ConvertUTCTime(&my_time, ( utcEpochTime - 944006400 )  //944006400 is used as we have calculated utcEpochTime from Jan 01 1970. (UTC)

When i read my_time variable it gives me following values

my_time.seconds = 25;
my_time.minutes = 03;
 my_time.hour = 04;
my_time.day = 0;
my_time.month = 6;
my_time.year = 2019;

1.Why i am getting month as 6 and day as 0, everything else is correct ?

2. If i calculate thee same for any other date its working fine.

3. What is the solution for this?

  • Hello akshay,

    There may be a bug in the OSAL_Clock driver that misinterprets the last day of months containing 31 days, you could test this by evaluating January, March, etc. Once this is known you can modify the driver or add logic to your application to compensate.

    Regards,
    Ryan
  • Hello Ryan,

    I made changes in osal_ConvertUTCTime function now i am getting proper date and time for months except February & December.

    As per the logic written for conversion i i put any date in month of December i am getting following converted value:

    If i pass time in sec with date 24 december 2019 then the converted value i am getting
    my_time.day = 24;
    my_time.month = 0;
    my_time.year = 2020;

    I think i need to rewrite some logic for driver function for this issue as well.
  • Glad to hear you are making progress, you can continue to debug osal_ConvertUTCTime to figure out why the logic is rolling over into a new year. You can further evaluate using the month of December with other years to figure out when the behavior occurs.

    Regards,
    Ryan