#include <stdio.h>
#include <time.h>
typedef struct hour{
int hour;
int minute;
int second;
int isdst;
} Hour;
typedef struct date{
int day;
int month;
int year;
Hour hr;
} Date;
int main (void) {
Date d;
time_t now = time(0);
struct tm temp;
char buffer[80];
const char *format = "%m-%d-%Y %H:%M:%S";
// get current local date and time ...
localtime_r( &now, &temp );
// ... storing it in date structure ...
d.day = temp.tm_mday;
d.month = temp.tm_mon;
d.year = temp.tm_year;
d.hr.hour = temp.tm_hour;
d.hr.minute = temp.tm_min;
d.hr.second = temp.tm_sec;
d.hr.isdst = temp.tm_isdst;
// ... and may safely display
strftime (buffer, 80, format, &temp);
printf("Current local date and time: %s",buffer);
return(0);
}