Skip to content

Instantly share code, notes, and snippets.

@giljr
Last active November 29, 2020 14:34
Show Gist options
  • Save giljr/7ad17e67b6ca9c6ea760ccf7cc564ca2 to your computer and use it in GitHub Desktop.
Save giljr/7ad17e67b6ca9c6ea760ccf7cc564ca2 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#define TRUE 1
#define FALSE 0
struct Date
{
unsigned int day;
unsigned int month;
unsigned int year;
unsigned int status;
};
struct Date date_init(struct Date dt)
{
dt.day = 01;
dt.month = 11;
dt.year = 2020;
dt.status = 1;
return dt;
}
struct Date date_modify(struct Date dt, int day, int month, int year)
{
dt.day = day;
dt.month = month;
dt.year = year;
if (validate())
{
dt.status = TRUE;
}
else
{
dt.status = FALSE;
}
return dt;
}
int validate()
{
// Hardware Serial initialization stake goes here!
return FALSE;
//return TRUE;
}
void date_print(const struct Date dt)
{
if(dt.status)
{
printf("Date:\nDay=%d\nMonth=%d\nYear=%d\nStatus=%d\n\n", dt.day, dt.month, dt.year,dt.status);
}
else
{
printf("Error: Object initialization Problem:\\\nPlease, Verify your Serial Port of your Iot Hardware.\n");
}
}
main()
{
struct Date clock;
//UART_Init(9600);
clock = date_init(clock);
date_print(clock);
clock = date_modify(clock, 28, 11, 2020);
//clock.day = 28;
//clock.month = 11;
//clock.year = 2020;
//clock.status = 0;
date_print(clock);
//printf("Date:\nDay=%d\nMonth=%d\nYear=%d\nStatus=%d", dt.day, dt.month, dt.year,dt.status);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment