+fw3_format_time(struct fw3_time *time)
+{
+ int i;
+ struct tm empty = { 0 };
+ char buf[sizeof("9999-99-99T23:59:59\0")];
+ bool d1 = memcmp(&time->datestart, &empty, sizeof(empty));
+ bool d2 = memcmp(&time->datestop, &empty, sizeof(empty));
+ bool first;
+
+ if (!d1 && !d2 && !time->timestart && !time->timestop &&
+ !(time->monthdays & 0xFFFFFFFE) && !(time->weekdays & 0xFE))
+ {
+ return;
+ }
+
+ fw3_pr(" -m time");
+
+ if (time->utc)
+ fw3_pr(" --utc");
+
+ if (d1)
+ {
+ strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S", &time->datestart);
+ fw3_pr(" --datestart %s", buf);
+ }
+
+ if (d2)
+ {
+ strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S", &time->datestop);
+ fw3_pr(" --datestop %s", buf);
+ }
+
+ if (time->timestart)
+ {
+ fw3_pr(" --timestart %02d:%02d:%02d",
+ time->timestart / 3600,
+ time->timestart % 3600 / 60,
+ time->timestart % 60);
+ }
+
+ if (time->timestop)
+ {
+ fw3_pr(" --timestop %02d:%02d:%02d",
+ time->timestop / 3600,
+ time->timestop % 3600 / 60,
+ time->timestop % 60);
+ }
+
+ if (time->monthdays & 0xFFFFFFFE)
+ {
+ fw3_pr(" %s--monthdays", hasbit(time->monthdays, 0) ? "! " : "");
+
+ for (i = 1, first = true; i < 32; i++)
+ {
+ if (hasbit(time->monthdays, i))
+ {
+ fw3_pr("%c%u", first ? ' ' : ',', i);
+ first = false;
+ }
+ }
+ }
+
+ if (time->weekdays & 0xFE)
+ {
+ fw3_pr(" %s--weekdays", hasbit(time->weekdays, 0) ? "! " : "");
+
+ for (i = 1, first = true; i < 8; i++)
+ {
+ if (hasbit(time->weekdays, i))
+ {
+ fw3_pr("%c%u", first ? ' ' : ',', i);
+ first = false;
+ }
+ }
+ }
+}
+
+void