Modified colors for due_date and reverted to yyyy-mm-dd

This commit is contained in:
xavi 2024-10-07 11:56:23 -07:00
parent f6d1b03c18
commit c094fad433
3 changed files with 18 additions and 14 deletions

View File

@ -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);

View File

@ -7,7 +7,7 @@ CREATE TABLE tasks(
due_date TEXT,
CHECK (
due_date IS NULL OR
due_date GLOB '??-??-????'
due_date GLOB '????-??-??'
)
);

View File

@ -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)