Get Wday for DS1307RTC

i want to show Day Of Week, can you help me? here my code but showed: hour, minutes, seconds, date, month, year from my laptop( i guess it).
bool getTime(const char *str)
{
int Hour, Min, Sec;

if (sscanf(str, "%d:%d:%d", &Hour, &Min, &Sec) != 3) return false;
tm.Hour = Hour;
tm.Minute = Min;
tm.Second = Sec;
return true;
}

bool getDate(const char *str)
{
char Month[12];
int Day, Year,WeekDay;
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);

return true;
}
. could you tell me how i should?
P/s: Sorry about my ENG

I think you have to tell the 1307 what the DOW is.

Arsace1:
. could you tell me how i should?

There are calendar algorithms to calculate Day Of Week from a given date by year, month, day.

Algorithm may be very simple if you only need Day Of Week within the same century, i.e. 1/1/2000 until 31/12/2099

DofWeek Algorithm is a bit more complicated if you need calculations for several different centuries.

here is my code Get DAYOFWEEK
void Thungay(){
month2 = month1;
year2 = year1;
if (month2 < 3)
{month2 +=12;
--year2;}
wday =( (day1 + (13 * month2 - 27) / 5 + year2 + year2/4 - year2/100 + year2/400) % 7) +1;
}
but i want to get tm.Wday from my laptop.
can you tell me how i use it :slight_smile:
makeTime(tm);

Convert normal date & time to a time_t number. The time_t number is returned. The tm input is a TimeElements variable type, which has these fields:

tm.Second Seconds 0 to 59
tm.Minute Minutes 0 to 59
tm.Hour Hours 0 to 23
tm.Wday Week Day 0 to 6 (not needed for mktime)
tm.Day Day 1 to 31
tm.Month Month 1 to 12
tm.Year Year 0 to 99 (offset from 1970)