insert_event #1
@ -19,6 +19,12 @@ DTSTART;TZID=/freeassociation.sourceforge.net/Continent/City:
|
|||||||
DTEND;TZID=/freeassociation.sourceforge.net/Continent/City:
|
DTEND;TZID=/freeassociation.sourceforge.net/Continent/City:
|
||||||
20230909T093000
|
20230909T093000
|
||||||
|
|
||||||
This includes the continent and city of the used time zone.
|
appointments can also span over multiple days:
|
||||||
|
DTSTART;TZID=/freeassociation.sourceforge.net/Europe/Berlin:
|
||||||
|
20230913T230000
|
||||||
|
DTEND;TZID=/freeassociation.sourceforge.net/Europe/Berlin:
|
||||||
|
20230914T040000
|
||||||
|
|
||||||
|
Appointments include the continent and city of the used time zone.
|
||||||
|
|
||||||
"DESCRIPTION:" is an optional field.
|
"DESCRIPTION:" is an optional field.
|
||||||
|
@ -18,11 +18,10 @@ void insert_event(char *file_name) {
|
|||||||
char dtstamp[] = "YYYYmmddTHHMMSSZ";
|
char dtstamp[] = "YYYYmmddTHHMMSSZ";
|
||||||
char *time_zone = get_tz();
|
char *time_zone = get_tz();
|
||||||
char *dtstart_buffer = malloc(128);
|
char *dtstart_buffer = malloc(128);
|
||||||
|
char *dtend_buffer = malloc(128);
|
||||||
|
|
||||||
remove_until_delim(time_zone, '/', 4);
|
remove_until_delim(time_zone, '/', 4);
|
||||||
|
|
||||||
printf ("tz is: %s\n", time_zone);
|
|
||||||
|
|
||||||
printf("Insert a new event\n");
|
printf("Insert a new event\n");
|
||||||
|
|
||||||
printf("Is this an all day event? [y/n] ");
|
printf("Is this an all day event? [y/n] ");
|
||||||
@ -51,10 +50,13 @@ void insert_event(char *file_name) {
|
|||||||
|
|
||||||
get_date(dtstamp);
|
get_date(dtstamp);
|
||||||
|
|
||||||
get_dtstart(dtstart_buffer, all_day_event);
|
get_dtstart_dtend(dtstart_buffer, all_day_event, "start");
|
||||||
marshall_date_time(dtstart_buffer);
|
marshall_date_time(dtstart_buffer);
|
||||||
form_dtstart_string(dtstart_buffer, time_zone);
|
form_dtstart_string(dtstart_buffer, time_zone);
|
||||||
|
|
||||||
|
get_dtstart_dtend(dtend_buffer, all_day_event, "end");
|
||||||
|
printf ("dtend_buffer: %s\n", dtend_buffer);
|
||||||
|
|
||||||
seek_cal_end(myfd);
|
seek_cal_end(myfd);
|
||||||
write(myfd, "BEGIN:VEVENT\r\n", strlen("BEGIN:VEVENT\r\n"));
|
write(myfd, "BEGIN:VEVENT\r\n", strlen("BEGIN:VEVENT\r\n"));
|
||||||
write(myfd, "UID:", strlen("UID:"));
|
write(myfd, "UID:", strlen("UID:"));
|
||||||
@ -70,6 +72,7 @@ void insert_event(char *file_name) {
|
|||||||
close(myfd);
|
close(myfd);
|
||||||
free(time_zone);
|
free(time_zone);
|
||||||
free(dtstart_buffer);
|
free(dtstart_buffer);
|
||||||
|
free(dtend_buffer);
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
@ -115,9 +118,10 @@ int binary_user_choice() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_dtstart(char input_buffer[], int all_day_event) {
|
// char *start_or_end should contain "start" or "end"
|
||||||
|
void get_dtstart_dtend(char input_buffer[], int all_day_event, char *start_or_end) {
|
||||||
if (all_day_event) {
|
if (all_day_event) {
|
||||||
printf("Enter the start date in YYYY-mm-dd format!\n");
|
printf("Enter the %s date in YYYY-mm-dd format!\n", start_or_end);
|
||||||
if (fgets(input_buffer, 128, stdin) == NULL) {
|
if (fgets(input_buffer, 128, stdin) == NULL) {
|
||||||
perror ("fgets");
|
perror ("fgets");
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -127,7 +131,7 @@ void get_dtstart(char input_buffer[], int all_day_event) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
printf("Enter the start date in YYYY-mm-dd HH:MM:SS format!\n");
|
printf("Enter the %s date in YYYY-mm-dd HH:MM:SS format!\n", start_or_end);
|
||||||
if (fgets(input_buffer, 128, stdin) == NULL) {
|
if (fgets(input_buffer, 128, stdin) == NULL) {
|
||||||
perror ("fgets");
|
perror ("fgets");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -3,5 +3,5 @@
|
|||||||
void insert_event(char *file_name);
|
void insert_event(char *file_name);
|
||||||
void seek_cal_end(int fd);
|
void seek_cal_end(int fd);
|
||||||
int binary_user_choice();
|
int binary_user_choice();
|
||||||
void get_dtstart(char input_buffer[], int all_day_event);
|
void get_dtstart_dtend(char input_buffer[], int all_day_event, char *start_or_end);
|
||||||
void form_dtstart_string(char dtstart_buffer[], char time_zone[]);
|
void form_dtstart_string(char dtstart_buffer[], char time_zone[]);
|
||||||
|
Loading…
Reference in New Issue
Block a user