Bug - DS1307RTC - example:SetTime - weekday not set correctly

maruta

New member
I found SetTime example in DS1307RTC Library does not set the weekday correctly.

Adding two lines to getDate function in SetTime example will solve the problem.
The following is the fixed getDate function.

Code:
bool getDate(const char *str)
{
  char Month[12];
  int Day, Year;
  uint8_t monthIndex;

  if (sscanf(str, "%s %d %d", Month, &Day, &Year) != 3) return false;
  for (monthIndex = 0; monthIndex < 12; monthIndex++) {
    if (strcmp(Month, monthName[monthIndex]) == 0) break;
  }
  if (monthIndex >= 12) return false;
  tm.Day = Day;
  tm.Month = monthIndex + 1;
  tm.Year = CalendarYrToTm(Year);

  time_t t=makeTime(tm);   // added
  breakTime(t,tm);         // added

  return true;
}

Thanks,
Maruta
 
Back
Top