46 lines
847 B
C
46 lines
847 B
C
//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>
|
|
#endif
|
|
//DATE
|
|
typedef struct date{
|
|
int day;
|
|
int month;
|
|
int year;
|
|
};
|
|
|
|
|
|
struct date convert_to_date(char* date){
|
|
struct date d;
|
|
char* token = strtok(date, "-");
|
|
d.day = atoi(token);
|
|
token = strtok(NULL, "-");
|
|
d.month = atoi(token);
|
|
token = strtok(NULL, "-");
|
|
d.year = atoi(token);
|
|
return d;
|
|
}
|
|
|
|
//TIME
|
|
|
|
typedef struct time{
|
|
int hour;
|
|
int minute;
|
|
int second;
|
|
};
|
|
|
|
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;
|
|
} |