                 lcd.setCursor(6, line);
                 break;
             case 3:
-                if (val < 0)  val = 31; // this allows to set 31.02 as a date
-                if (val > 31) val = 0;
+                if (val < 1)  val = 31; // this allows to set 31.02 as a date
+                if (val > 31) val = 1;
                 rtc.setDate(val);
                 lcd.setCursor(10, line);
                 if (val < 10)


// Real-time clock
DS3231 rtc;

// Error value
const int32_t err_val = 200000;


    //print_clock(); // Optional

    byte ret;
    bool tmp1, tmp2;

    // second
    ret = last_second;
    time_format[6] = ret / 10 + ('0');
    time_format[7] = ret % 10 + ('0');

    if (ret != 0 && !full_update)
	goto end;

    // minute
    ret = rtc.getMinute();
    time_format[3] = ret / 10 + ('0');
    time_format[4] = ret % 10 + ('0');

    if (ret != 0 && !full_update)
	goto end;

    // hour
    ret = rtc.getHour(tmp1, tmp2);
    time_format[0] = ret / 10 + ('0');
    time_format[1] = ret % 10 + ('0');

    if (ret != 0 && !full_update)
	goto end;

    // Update all date string - very little optimization gain

    // day
    ret = rtc.getDate();
    time_format[10] = ret / 10 + ('0');
    time_format[11] = ret % 10 + ('0');

    // month
    ret = rtc.getMonth(tmp1);
    time_format[13] = ret / 10 + ('0');
    time_format[14] = ret % 10 + ('0');

    // year - only last two digits
    ret = rtc.getYear();

    time_format[18] = ret / 10 + ('0');
    time_format[19] = ret % 10 + ('0');

end:
    LOGLN(time_format);
    lcd.setCursor(0, row);
    lcd.print(time_format);
}

////////////////////////////////////////////////////////////////////////////////
