1 /*-
2  * SPDX-License-Identifier: CC0-1.0
3  *
4  * Written in 2022 by Alfonso Sabato Siciliano.
5  * To the extent possible under law, the author has dedicated all copyright
6  * and related and neighboring rights to this software to the public domain
7  * worldwide. This software is distributed without any warranty, see:
8  *   <http://creativecommons.org/publicdomain/zero/1.0/>.
9  */
10 
11 #include <bsddialog.h>
12 #include <stdio.h>
13 #include <time.h>
14 
main()15 int main()
16 {
17 	int output;
18 	unsigned int yy, mm, dd;
19 	struct bsddialog_conf conf;
20 	time_t cal;
21 	struct tm *localtm;
22 
23 	time(&cal);
24 	localtm = localtime(&cal);
25 	yy = localtm->tm_year + 1900;
26 	mm = localtm->tm_mon + 1;
27 	dd = localtm->tm_mday;
28 
29 	if (bsddialog_init() == BSDDIALOG_ERROR) {
30 		printf("Error: %s\n", bsddialog_geterror());
31 		return (1);
32 	}
33 	bsddialog_initconf(&conf);
34 	conf.title = "calendar";
35 	output = bsddialog_calendar(&conf, "Example", 18, 40, &yy, &mm, &dd);
36 	bsddialog_end();
37 	if (output == BSDDIALOG_ERROR) {
38 		printf("Error: %s\n", bsddialog_geterror());
39 		return (1);
40 	}
41 
42 	printf("Date: %u/%u/%u\n", yy, mm, dd);
43 
44 	return (0);
45 }