fix-end-date-printing #2
@ -42,6 +42,6 @@ sudo make uninstall
|
||||
|
||||
#### TODO
|
||||
|
||||
- fix bug when LOCATION field is present
|
||||
- cap the number of upcoming events being printed (and introduce --all option)
|
||||
- don't show the DTEND day of an all day event, but DTEND - 1
|
||||
- tests
|
||||
|
@ -70,7 +70,10 @@ void print_end_date(char end_date[], char start_date[]) {
|
||||
return;
|
||||
} else {
|
||||
printf (" - ");
|
||||
pretty_print_date_time(end_date);
|
||||
end_uts -= 86400;
|
||||
char *end_date_minus_one = transform_unix_ts_to_date(end_uts);
|
||||
pretty_print_date_time(end_date_minus_one);
|
||||
free(end_date_minus_one);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@ -110,6 +113,17 @@ time_t transform_date_to_unix_ts(char date_str[]) {
|
||||
return unix_stamp;
|
||||
}
|
||||
|
||||
// unix timestamp -> YYYYmmdd
|
||||
// make sure to free the returned buffer
|
||||
char *transform_unix_ts_to_date(time_t unix_ts) {
|
||||
char *date_buffer = malloc(9);
|
||||
struct tm *my_tm;
|
||||
my_tm = localtime(&unix_ts);
|
||||
strftime(date_buffer, 9, "%Y%m%d", my_tm);
|
||||
|
||||
return date_buffer;
|
||||
}
|
||||
|
||||
char *get_tz() {
|
||||
char *timezone_path = malloc(256);
|
||||
ssize_t bytes_read = readlink("/etc/localtime", timezone_path, 255);
|
||||
|
@ -7,3 +7,4 @@ void pretty_print_date_time(char date_time[]);
|
||||
void marshall_date_time(char date_time[]);
|
||||
void print_end_date(char end_date[], char start_date[]);
|
||||
time_t transform_date_to_unix_ts(char date_str[]);
|
||||
char *transform_unix_ts_to_date(time_t unix_ts);
|
||||
|
Loading…
Reference in New Issue
Block a user