Path: blob/main/contrib/bsddialog/examples_library/datebox.c
39530 views
/*-1* SPDX-License-Identifier: CC0-1.02*3* Written in 2021 by Alfonso Sabato Siciliano.4* To the extent possible under law, the author has dedicated all copyright5* and related and neighboring rights to this software to the public domain6* worldwide. This software is distributed without any warranty, see:7* <http://creativecommons.org/publicdomain/zero/1.0/>.8*/910#include <bsddialog.h>11#include <stdio.h>12#include <time.h>1314int main()15{16int output;17unsigned int yy, mm, dd;18struct bsddialog_conf conf;19time_t cal;20struct tm *localtm;2122time(&cal);23localtm = localtime(&cal);24yy = localtm->tm_year + 1900;25mm = localtm->tm_mon + 1;26dd = localtm->tm_mday;2728if (bsddialog_init() == BSDDIALOG_ERROR) {29printf("Error: %s\n", bsddialog_geterror());30return (1);31}32bsddialog_initconf(&conf);33conf.title = "datebox";34output = bsddialog_datebox(&conf, "Example", 9, 35, &yy, &mm, &dd);35bsddialog_end();36if (output == BSDDIALOG_ERROR) {37printf("Error: %s\n", bsddialog_geterror());38return (1);39}40printf("Date: %u/%u/%u\n", yy, mm, dd);4142return (0);43}4445