This patch allows to override the time() and define a different time by
TEST_TIME env. variable. The code has to be compiled with -DTEST_CAL.
Signed-off-by: Karel Zak <kzak@redhat.com>
endif
endif
+
+noinst_PROGRAMS = cal_test
+cal_test_SOURCES = cal.c
+cal_test_CPPFLAGS = -DTEST_CAL $(AM_CPPFLAGS)
+cal_test_LDADD = $(cal_LDADD)
+
errx(1, _("illegal year value: use 1-9999"));
break;
case 0:
- time(&now);
+ {
+#ifdef TEST_CAL
+ char *e = getenv("TEST_TIME");
+
+ if (e && isdigit((unsigned char) *e))
+ now = atol(e);
+ else
+#endif
+ time(&now);
+ }
local_time = localtime(&now);
if (isatty(1))
day = local_time->tm_yday + 1;