summaryrefslogtreecommitdiffstats
path: root/src/event.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/event.c')
-rw-r--r--src/event.c43
1 files changed, 20 insertions, 23 deletions
diff --git a/src/event.c b/src/event.c
index c395ed8..64bc3eb 100644
--- a/src/event.c
+++ b/src/event.c
@@ -45,21 +45,21 @@ llist_t eventlist;
static struct event bkp_cut_event;
void
-event_free_bkp (enum eraseflg flag)
+event_free_bkp (void)
{
if (bkp_cut_event.mesg)
{
mem_free (bkp_cut_event.mesg);
bkp_cut_event.mesg = 0;
}
- erase_note (&bkp_cut_event.note, flag);
+ erase_note (&bkp_cut_event.note);
}
static void
event_free (struct event *ev)
{
mem_free (ev->mesg);
- erase_note (&ev->note, ERASE_FORCE_KEEP_NOTE);
+ erase_note (&ev->note);
mem_free (ev);
}
@@ -91,7 +91,7 @@ event_llist_free (void)
static int
event_cmp_day (struct event *a, struct event *b)
{
- return (a->day < b->day ? -1 : (a->day == b->day ? 0 : 1));
+ return a->day < b->day ? -1 : (a->day == b->day ? 0 : 1);
}
/* Create a new event */
@@ -115,11 +115,11 @@ event_new (char *mesg, char *note, long day, int id)
unsigned
event_inday (struct event *i, long start)
{
- if (i->day <= start + DAYINSEC && i->day > start)
+ if (i->day < start + DAYINSEC && i->day >= start)
{
- return (1);
+ return 1;
}
- return (0);
+ return 0;
}
/* Write to file the event in user-friendly format */
@@ -131,11 +131,11 @@ event_write (struct event *o, FILE *f)
t = o->day;
lt = localtime (&t);
- (void)fprintf (f, "%02u/%02u/%04u [%d] ", lt->tm_mon + 1, lt->tm_mday,
- 1900 + lt->tm_year, o->id);
+ fprintf (f, "%02u/%02u/%04u [%d] ", lt->tm_mon + 1, lt->tm_mday,
+ 1900 + lt->tm_year, o->id);
if (o->note != NULL)
- (void)fprintf (f, ">%s ", o->note);
- (void)fprintf (f, "%s\n", o->mesg);
+ fprintf (f, ">%s ", o->note);
+ fprintf (f, "%s\n", o->mesg);
}
/* Load the events from file */
@@ -146,16 +146,16 @@ event_scan (FILE *f, struct tm start, int id, char *note)
time_t tstart, t;
t = time (NULL);
- (void)localtime (&t);
+ localtime (&t);
/* Read the event description */
- (void)fgets (buf, sizeof buf, f);
+ fgets (buf, sizeof buf, f);
nl = strchr (buf, '\n');
if (nl)
{
*nl = '\0';
}
- start.tm_hour = 12;
+ start.tm_hour = 0;
start.tm_min = 0;
start.tm_sec = 0;
start.tm_isdst = -1;
@@ -194,18 +194,16 @@ event_delete_bynum (long start, unsigned num, enum eraseflg flag)
switch (flag)
{
case ERASE_FORCE_ONLY_NOTE:
- erase_note (&ev->note, flag);
+ erase_note (&ev->note);
break;
case ERASE_CUT:
- event_free_bkp (ERASE_FORCE);
+ event_free_bkp ();
event_dup (ev, &bkp_cut_event);
- erase_note (&ev->note, ERASE_FORCE_KEEP_NOTE);
+ erase_note (&ev->note);
/* FALLTHROUGH */
default:
LLIST_REMOVE (&eventlist, i);
mem_free (ev->mesg);
- if (flag != ERASE_FORCE_KEEP_NOTE && flag != ERASE_CUT)
- erase_note (&ev->note, flag);
mem_free (ev);
break;
}
@@ -214,8 +212,7 @@ event_delete_bynum (long start, unsigned num, enum eraseflg flag)
void
event_paste_item (void)
{
- (void)event_new (bkp_cut_event.mesg, bkp_cut_event.note,
- date2sec (*calendar_get_slctd_day (), 12, 0),
- bkp_cut_event.id);
- event_free_bkp (ERASE_FORCE_KEEP_NOTE);
+ event_new (bkp_cut_event.mesg, bkp_cut_event.note,
+ date2sec (*calendar_get_slctd_day (), 0, 0), bkp_cut_event.id);
+ event_free_bkp ();
}