Vergewissern Sie sich, dass die Seite in der deutschen Sprache angezeigt wird (nicht übersetzt). Der Code wird sonst leicht verändert.
char dayOfWeek[16]; char month[16]; int secondsSince2009; int nEvents; while (TRUE) { nEvents = getinputevent(); if (nEvents & 0x08) { secondsSince2009 = getinput(0); // Divide secondsSince2009 by 86400 and make an integer of the result int daysSince2009 = secondsSince2009 / 86400; // Compute the remainder after dividing by 7 for day of the week int remainder = daysSince2009 % 7; // Map remainder to text output for day of the week // where Loxone epoch 1/1/2009 was a Thursday switch (remainder) { case 0: strcpy(dayOfWeek, "Thursday"); break; case 1: strcpy(dayOfWeek, "Friday"); break; case 2: strcpy(dayOfWeek, "Saturday"); break; case 3: strcpy(dayOfWeek, "Sunday"); break; case 4: strcpy(dayOfWeek, "Monday"); break; case 5: strcpy(dayOfWeek, "Tuesday"); break; case 6: strcpy(dayOfWeek, "Wednesday"); break; default: // Handle invalid remainder value strcpy(dayOfWeek, "Invalid"); break; } // Extract year, month, day, hour, minute, and second. // Timezone is the same timezone referenced in input. int year = getyear(secondsSince2009, 0); int monthNum = getmonth(secondsSince2009, 0); int day = getday(secondsSince2009, 0); int hour = gethour(secondsSince2009, 0); int minute = getminute(secondsSince2009, 0); int second = getsecond(secondsSince2009, 0); // Map month number to text output using switch switch (monthNum) { case 1: strcpy(month, "January"); break; case 2: strcpy(month, "February"); break; case 3: strcpy(month, "March"); break; case 4: strcpy(month, "April"); break; case 5: strcpy(month, "May"); break; case 6: strcpy(month, "June"); break; case 7: strcpy(month, "July"); break; case 8: strcpy(month, "August"); break; case 9: strcpy(month, "September"); break; case 10: strcpy(month, "October"); break; case 11: strcpy(month, "November"); break; case 12: strcpy(month, "December"); break; default: // Handle invalid month number strcpy(month, "Invalid"); break; } // Convert to EIB date and timegroup int dategroup = (day * 65536) + (monthNum * 256) + (year - 2000); // EIB date int timegroup = (hour * 65536) + (minute * 256) + second; // EIB time // Print dategroup, timegroup, year, // month, day, hour, minute, and second setoutput(0, dategroup); setoutput(1, timegroup); setoutput(2, year); setoutput(3, monthNum); setoutput(4, day); setoutput(5, hour); setoutput(6, minute); setoutput(7, second); // Output the day of the week and month as text setoutputtext(0, month); setoutputtext(1, dayOfWeek); } sleep(500); }
Kommentar