//include std lib if they havent been included
#ifndef STD_LIB_H
#define STD_LIB_H
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#include<math.h>
#include<time.h>
#include<ctype.h>
#endif
//DATE
typedef struct Date{
    int day;
    int month;
    int year;
}Date;


struct Date convert_to_date(char* date){
    struct Date d;
    char* token = strtok(date, "-");
    d.year = atoi(token);
    token = strtok(NULL, "-");
    d.month = atoi(token);
    token = strtok(NULL, "-");
    d.day = atoi(token);
    return d;
}

struct Date get_date(){
    struct Date d;
    time_t rawtime;
    struct tm * timeinfo;
    time(&rawtime);
    timeinfo = localtime(&rawtime);
    d.day = timeinfo->tm_mday;
    d.month = timeinfo->tm_mon + 1;
    d.year = timeinfo->tm_year + 1900;
    return d;
}

//TIME

typedef struct Time{
    int hour;
    int minute;
    int second;
}Time;

struct Time convert_to_time(char* time){
    struct Time t;
    char* token = strtok(time, ":");
    t.hour = atoi(token);
    token = strtok(NULL, ":");
    t.minute = atoi(token);
    token = strtok(NULL, ":");
    t.second = atoi(token);
    return t;
}

struct Time get_time(){
    struct Time t;
    time_t rawtime;
    struct tm * timeinfo;
    time(&rawtime);
    timeinfo = localtime(&rawtime);
    t.hour = timeinfo->tm_hour;
    t.minute = timeinfo->tm_min;
    t.second = timeinfo->tm_sec;
    return t;
}