Modified colors for due_date and reverted to yyyy-mm-dd
This commit is contained in:
parent
f6d1b03c18
commit
c094fad433
29
src/dodo.c
29
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));
|
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;
|
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){
|
int extract_date(const char *due_date, date *d){
|
||||||
char temp[5];
|
char temp[5];
|
||||||
|
|
||||||
temp[0] = due_date[0];
|
// day
|
||||||
temp[1] = due_date[1];
|
temp[0] = due_date[8];
|
||||||
|
temp[1] = due_date[9];
|
||||||
temp[2] = '\0';
|
temp[2] = '\0';
|
||||||
|
|
||||||
d->day = atoi(temp);
|
d->day = atoi(temp);
|
||||||
|
|
||||||
temp[0] = due_date[3];
|
// month
|
||||||
temp[1] = due_date[4];
|
temp[0] = due_date[5];
|
||||||
|
temp[1] = due_date[6];
|
||||||
temp[2] = '\0';
|
temp[2] = '\0';
|
||||||
|
|
||||||
d->month = atoi(temp);
|
d->month = atoi(temp);
|
||||||
|
|
||||||
temp[0] = due_date[6];
|
// year
|
||||||
temp[1] = due_date[7];
|
temp[0] = due_date[0];
|
||||||
temp[2] = due_date[8];
|
temp[1] = due_date[1];
|
||||||
temp[3] = due_date[9];
|
temp[2] = due_date[2];
|
||||||
|
temp[3] = due_date[3];
|
||||||
temp[4] = '\0';
|
temp[4] = '\0';
|
||||||
|
|
||||||
d->year = atoi(temp);
|
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);
|
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);
|
printf("%s", X_GREEN);
|
||||||
}
|
}
|
||||||
else if ( days_until_due_date > 7 ){
|
else if ( days_until_due_date > 4 ){
|
||||||
printf("%s", X_YELLOW);
|
printf("%s", X_YELLOW);
|
||||||
}
|
}
|
||||||
else if ( days_until_due_date > 3 ){
|
else if ( days_until_due_date > 2 ){
|
||||||
printf("%s", X_YELLOW);
|
printf("%s", X_ORANGE);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
printf("%s", X_RED);
|
printf("%s", X_RED);
|
||||||
|
@ -7,7 +7,7 @@ CREATE TABLE tasks(
|
|||||||
due_date TEXT,
|
due_date TEXT,
|
||||||
CHECK (
|
CHECK (
|
||||||
due_date IS NULL OR
|
due_date IS NULL OR
|
||||||
due_date GLOB '??-??-????'
|
due_date GLOB '????-??-??'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#define X_UNDL "\x1B[21m"
|
#define X_UNDL "\x1B[21m"
|
||||||
#define X_CYN "\x1B[36m"
|
#define X_CYN "\x1B[36m"
|
||||||
#define X_YELLOW "\x1B[38;5;226m"
|
#define X_YELLOW "\x1B[38;5;226m"
|
||||||
|
#define X_ORANGE "\x1B[38;5;202m"
|
||||||
#define X_GREEN "\x1B[32m"
|
#define X_GREEN "\x1B[32m"
|
||||||
#define X_RED "\x1B[31m"
|
#define X_RED "\x1B[31m"
|
||||||
#define X_goup(y) printf("\x1B[%dF", y)
|
#define X_goup(y) printf("\x1B[%dF", y)
|
||||||
|
Loading…
Reference in New Issue
Block a user