diff --git a/src/dodo.c b/src/dodo.c index 281f76c..3723c39 100644 --- a/src/dodo.c +++ b/src/dodo.c @@ -119,7 +119,7 @@ int get_due_date(filtered_tasks *task, char* passed_date){ } task->due_date = malloc(ARG_MAX * sizeof(char)); - snprintf(task->due_date, ARG_MAX, "%02d-%02d-%04d", d->day, d->month, d->year); + snprintf(task->due_date, ARG_MAX, "%04d-%02d-%02d", d->year, d->month, d->day); return 0; } @@ -575,22 +575,25 @@ int get_num_days_between_dates(date *d1, date *d2){ int extract_date(const char *due_date, date *d){ char temp[5]; - temp[0] = due_date[0]; - temp[1] = due_date[1]; + // day + temp[0] = due_date[8]; + temp[1] = due_date[9]; temp[2] = '\0'; d->day = atoi(temp); - temp[0] = due_date[3]; - temp[1] = due_date[4]; + // month + temp[0] = due_date[5]; + temp[1] = due_date[6]; temp[2] = '\0'; d->month = atoi(temp); - temp[0] = due_date[6]; - temp[1] = due_date[7]; - temp[2] = due_date[8]; - temp[3] = due_date[9]; + // year + temp[0] = due_date[0]; + temp[1] = due_date[1]; + temp[2] = due_date[2]; + temp[3] = due_date[3]; temp[4] = '\0'; d->year = atoi(temp); @@ -614,14 +617,14 @@ int set_color_of_date(const char *due_date){ days_until_due_date = get_num_days_between_dates(today, d); - if ( days_until_due_date > 14 ){ + if ( days_until_due_date > 6 ){ printf("%s", X_GREEN); } - else if ( days_until_due_date > 7 ){ + else if ( days_until_due_date > 4 ){ printf("%s", X_YELLOW); } - else if ( days_until_due_date > 3 ){ - printf("%s", X_YELLOW); + else if ( days_until_due_date > 2 ){ + printf("%s", X_ORANGE); } else{ printf("%s", X_RED); diff --git a/src/dodo.schema b/src/dodo.schema index 5ccebc8..28e16f9 100644 --- a/src/dodo.schema +++ b/src/dodo.schema @@ -7,7 +7,7 @@ CREATE TABLE tasks( due_date TEXT, CHECK ( due_date IS NULL OR - due_date GLOB '??-??-????' + due_date GLOB '????-??-??' ) ); diff --git a/src/x_curses.h b/src/x_curses.h index 5ef3f1d..0e75d00 100644 --- a/src/x_curses.h +++ b/src/x_curses.h @@ -6,6 +6,7 @@ #define X_UNDL "\x1B[21m" #define X_CYN "\x1B[36m" #define X_YELLOW "\x1B[38;5;226m" +#define X_ORANGE "\x1B[38;5;202m" #define X_GREEN "\x1B[32m" #define X_RED "\x1B[31m" #define X_goup(y) printf("\x1B[%dF", y)