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.

Setting date to 29 March 2015 (daylight saving date) results in date to be reported as 1 April 2015

Other Parts Discussed in Thread: CC3200

- write 29 March 2015 as the date/time to the device.( This is the date on which Daylight savings time adjustment is applied, coincidentally)

- read back the currrent date and time.

- Date and Time read back is 1 Apr 2015.

- I was expecting to read back 29 March 2015.


code to write date/time:

 SlDateTime_t dateTime;
     dateTime.sl_tm_day =   (unsigned long)29;       
     dateTime.sl_tm_mon =   (unsigned long)2;      
     dateTime.sl_tm_year =  (unsigned long)2015;   
     dateTime.sl_tm_hour =  (unsigned long)18;     
     dateTime.sl_tm_min =   (unsigned long)0;      
     dateTime.sl_tm_sec =   (unsigned long)0;      
    
     (void)sl_DevSet((unsigned char)SL_DEVICE_GENERAL_CONFIGURATION, (unsigned char) SL_DEVICE_GENERAL_CONFIGURATION_DATE_TIME, (unsigned char)sizeof(SlDateTime_t), (unsigned char *)(&dateTime));
        

Setup : IAR compiler, CC3200, TI SDK 1.0.0.1.1

Why is this the reported date/time incorrect ? Is this a known issue ?

regards,

-AG

  • Hello,
    As per the documentation / comments in the SDK (see code below) the range for Month is described as 1-12.
    Setting device time and date example:
     
    SlDateTime_t dateTime= {0};
    dateTime.sl_tm_day = (_u32)23; // Day of month (DD format) range 1-13
    dateTime.sl_tm_mon = (_u32)6; // Month (MM format) in the range of 1-12
    dateTime.sl_tm_year = (_u32)2014; // Year (YYYY format)
    dateTime.sl_tm_hour = (_u32)17; // Hours in the range of 0-23
    dateTime.sl_tm_min = (_u32)55; // Minutes in the range of 0-59
    dateTime.sl_tm_sec = (_u32)22; // Seconds in the range of 0-59
    sl_DevSet(SL_DEVICE_GENERAL_CONFIGURATION,
    SL_DEVICE_GENERAL_CONFIGURATION_DATE_TIME,
    sizeof(SlDateTime_t),
    (_u8 *)(&dateTime));
    In practice this appears to be incorrect. The range that needs to be used is 0-11.
    Can someone confirm if the documentation is incorrect or correct ?
    regards,

    -AG

  • I was able to reproduce this result, which is the expected result. Let me explain.

    The code you displayed above sets the date to the 29th of February and as such, returning the 1st of March as the result is the correct behavior, as 2015 is not a leap year, which means that February only has 28 days this year.

    Glenn.

  • Many thanks for your quick reply. Could you also confirm what the range of values are for the Month field, is it 1-12 or is it 0-11 ?

    regards,
    -Ag
  • The following is documented in the SimpleLink API documentation found in the CC3200 SDK for the sl_DevSet method.

    SlDateTime_t dateTime= {0};
    dateTime.sl_tm_day = (_u32)23; // Day of month (DD format) range 1-13
    dateTime.sl_tm_mon = (_u32)6; // Month (MM format) in the range of 1-12
    dateTime.sl_tm_year = (_u32)2014; // Year (YYYY format)
    dateTime.sl_tm_hour = (_u32)17; // Hours in the range of 0-23
    dateTime.sl_tm_min = (_u32)55; // Minutes in the range of 0-59
    dateTime.sl_tm_sec = (_u32)22; // Seconds in the range of 0-59

    Glenn.
  • i just realized after posting, that the documentation contains a typo, as the day range should be 1-31 and not 1-13

    But either way, month is 1-12

    Glenn.
  • Hi Many thanks.

    I am using <time.h> library with the tm data structure. The tm structure has the month range 0-11, SlDateTime uses month range of 1-12.  I have now compensated for this delta in the date conversions now.  

    Also , thanks for confirming the day range typo.

    Happy to close this issue.

    regards,

    -AG

  • I doubt this has been taken into consideration, since it has just been announced :-)

    Glenn.