xref: /netbsd-src/external/bsd/ntp/dist/tests/libntp/test-libntp.c (revision 7330f729ccf0bd976a06f95fad452fe774fc7fd1)
1 #include <config.h>
2 
3 #include "ntp_stdlib.h"
4 #include "ntp_calendar.h"
5 
6 #include "test-libntp.h"
7 
8 
9 time_t nowtime = 0;
10 
11 
12 time_t
13 timefunc(time_t *ptr) {
14     if (ptr)
15 	*ptr = nowtime;
16     return nowtime;
17 }
18 
19 
20 void
21 settime(int y, int m, int d, int H, int M, int S) {
22 
23     time_t days = ntpcal_edate_to_eradays(y-1, m-1, d-1) + 1 - DAY_UNIX_STARTS;
24     time_t secs = ntpcal_etime_to_seconds(H, M, S);
25 
26     nowtime = days * SECSPERDAY + secs;
27 }
28