summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/apoint.c12
-rw-r--r--src/calcurse.h108
-rw-r--r--src/day.c28
-rw-r--r--src/event.c6
-rw-r--r--src/notify.c6
-rw-r--r--src/recur.c40
-rw-r--r--src/ui-calendar.c8
-rw-r--r--src/ui-day.c10
-rw-r--r--src/utils.c40
9 files changed, 129 insertions, 129 deletions
diff --git a/src/apoint.c b/src/apoint.c
index c195559..5a9802a 100644
--- a/src/apoint.c
+++ b/src/apoint.c
@@ -98,7 +98,7 @@ static int apoint_cmp(struct apoint *a, struct apoint *b)
return strcmp(a->mesg, b->mesg);
}
-struct apoint *apoint_new(char *mesg, char *note, long start, long dur,
+struct apoint *apoint_new(char *mesg, char *note, time_t start, long dur,
char state)
{
struct apoint *apt;
@@ -117,14 +117,14 @@ struct apoint *apoint_new(char *mesg, char *note, long start, long dur,
return apt;
}
-unsigned apoint_inday(struct apoint *i, long *start)
+unsigned apoint_inday(struct apoint *i, time_t *start)
{
return (date_cmp_day(i->start, *start) == 0 ||
(date_cmp_day(i->start, *start) < 0 &&
date_cmp_day(i->start + i->dur - 1, *start) >= 0));
}
-void apoint_sec2str(struct apoint *o, long day, char *start, char *end)
+void apoint_sec2str(struct apoint *o, time_t day, char *start, char *end)
{
struct tm lt;
time_t t;
@@ -278,7 +278,7 @@ void apoint_delete(struct apoint *apt)
LLIST_TS_UNLOCK(&alist_p);
}
-static int apoint_starts_after(struct apoint *apt, long *time)
+static int apoint_starts_after(struct apoint *apt, time_t *time)
{
return apt->start > *time;
}
@@ -287,7 +287,7 @@ static int apoint_starts_after(struct apoint *apt, long *time)
* Look in the appointment list if we have an item which starts before the item
* stored in the notify_app structure (which is the next item to be notified).
*/
-struct notify_app *apoint_check_next(struct notify_app *app, long start)
+struct notify_app *apoint_check_next(struct notify_app *app, time_t start)
{
llist_item_t *i;
@@ -324,7 +324,7 @@ void apoint_switch_notify(struct apoint *apt)
LLIST_TS_UNLOCK(&alist_p);
}
-void apoint_paste_item(struct apoint *apt, long date)
+void apoint_paste_item(struct apoint *apt, time_t date)
{
struct tm t;
diff --git a/src/calcurse.h b/src/calcurse.h
index 4e92808..0f3bd8a 100644
--- a/src/calcurse.h
+++ b/src/calcurse.h
@@ -335,7 +335,7 @@ struct date {
/* Appointment definition. */
struct apoint {
- long start; /* seconds since 1 jan 1970 */
+ time_t start; /* seconds since 1 jan 1970 */
long dur; /* duration of the appointment in seconds */
#define APOINT_NULL 0x0
@@ -350,7 +350,7 @@ struct apoint {
/* Event definition. */
struct event {
int id; /* event identifier */
- long day; /* seconds since 1 jan 1970 */
+ time_t day; /* seconds since 1 jan 1970 */
char *mesg;
char *note;
};
@@ -364,7 +364,7 @@ struct todo {
};
struct excp {
- long st; /* beggining of the considered day, in seconds */
+ time_t st; /* beggining of the considered day, in seconds */
};
enum recur_type {
@@ -380,14 +380,14 @@ enum recur_type {
struct rpt {
enum recur_type type; /* repetition type */
int freq; /* repetition frequency */
- long until; /* ending date for repeated event */
+ time_t until; /* ending date for repeated event */
};
/* Recurrent appointment definition. */
struct recur_apoint {
struct rpt *rpt; /* information about repetition */
llist_t exc; /* days when the item should not be repeated */
- long start; /* beggining of the appointment */
+ time_t start; /* beggining of the appointment */
long dur; /* duration of the appointment */
char state; /* 8 bits to store item state */
char *mesg; /* appointment description */
@@ -399,7 +399,7 @@ struct recur_event {
struct rpt *rpt; /* information about repetition */
llist_t exc; /* days when the item should not be repeated */
int id; /* event type */
- long day; /* day at which event occurs */
+ time_t day; /* day at which event occurs */
char *mesg; /* event description */
char *note; /* note attached to event */
};
@@ -459,13 +459,13 @@ struct item_filter {
/* Generic item description (to hold appointments, events...). */
struct day_item {
enum day_item_type type;
- long start;
+ time_t start;
union aptev_ptr item;
};
/* Shared variables for the notification threads. */
struct notify_app {
- long time;
+ time_t time;
int got_app;
char *txt;
char state;
@@ -742,18 +742,18 @@ struct apoint *apoint_dup(struct apoint *);
void apoint_free(struct apoint *);
void apoint_llist_init(void);
void apoint_llist_free(void);
-struct apoint *apoint_new(char *, char *, long, long, char);
-unsigned apoint_inday(struct apoint *, long *);
-void apoint_sec2str(struct apoint *, long, char *, char *);
+struct apoint *apoint_new(char *, char *, time_t, long, char);
+unsigned apoint_inday(struct apoint *, time_t *);
+void apoint_sec2str(struct apoint *, time_t, char *, char *);
char *apoint_tostr(struct apoint *);
char *apoint_hash(struct apoint *);
void apoint_write(struct apoint *, FILE *);
struct apoint *apoint_scan(FILE *, struct tm, struct tm, char, char *,
struct item_filter *);
void apoint_delete(struct apoint *);
-struct notify_app *apoint_check_next(struct notify_app *, long);
+struct notify_app *apoint_check_next(struct notify_app *, time_t);
void apoint_switch_notify(struct apoint *);
-void apoint_paste_item(struct apoint *, long);
+void apoint_paste_item(struct apoint *, time_t);
/* args.c */
int parse_args(int, char **);
@@ -779,8 +779,8 @@ void ui_calendar_update_panel(void);
void ui_calendar_goto_today(void);
void ui_calendar_change_day(int);
void ui_calendar_move(enum move, int);
-long ui_calendar_start_of_year(void);
-long ui_calendar_end_of_year(void);
+time_t ui_calendar_start_of_year(void);
+time_t ui_calendar_end_of_year(void);
/* config.c */
void config_load(void);
@@ -804,19 +804,19 @@ char *day_item_get_note(struct day_item *);
void day_item_erase_note(struct day_item *);
long day_item_get_duration(struct day_item *);
int day_item_get_state(struct day_item *);
-void day_item_add_exc(struct day_item *, long);
+void day_item_add_exc(struct day_item *, time_t);
void day_item_fork(struct day_item *, struct day_item *);
-void day_store_items(long, int);
+void day_store_items(time_t, int);
void day_process_storage(struct date *, unsigned);
-void day_display_item_date(struct day_item *, WINDOW *, int, long, int, int);
+void day_display_item_date(struct day_item *, WINDOW *, int, time_t, int, int);
void day_display_item(struct day_item *, WINDOW *, int, int, int, int);
-void day_write_stdout(long, const char *, const char *, const char *,
+void day_write_stdout(time_t, const char *, const char *, const char *,
const char *, int *);
void day_popup_item(struct day_item *);
int day_check_if_item(struct date);
unsigned day_chk_busy_slices(struct date, int, int *);
-struct day_item *day_cut_item(long, int);
-int day_paste_item(struct day_item *, long);
+struct day_item *day_cut_item(time_t, int);
+int day_paste_item(struct day_item *, time_t);
int day_get_position_by_aptev_ptr(union aptev_ptr);
int day_get_position(struct day_item *);
struct day_item *day_get_item(int);
@@ -836,14 +836,14 @@ struct event *event_dup(struct event *);
void event_free(struct event *);
void event_llist_init(void);
void event_llist_free(void);
-struct event *event_new(char *, char *, long, int);
-unsigned event_inday(struct event *, long *);
+struct event *event_new(char *, char *, time_t, int);
+unsigned event_inday(struct event *, time_t *);
char *event_tostr(struct event *);
char *event_hash(struct event *);
void event_write(struct event *, FILE *);
struct event *event_scan(FILE *, struct tm, int, char *, struct item_filter *);
void event_delete(struct event *);
-void event_paste_item(struct event *, long);
+void event_paste_item(struct event *, time_t);
/* getstring.c */
enum getstr getstring(WINDOW *, char *, int, int, int);
@@ -982,7 +982,7 @@ void note_gc(void);
/* notify.c */
int notify_time_left(void);
unsigned notify_needs_reminder(void);
-void notify_update_app(long, char, char *);
+void notify_update_app(time_t, char, char *);
int notify_bar(void);
void notify_init_vars(void);
void notify_init_bar(void);
@@ -996,9 +996,9 @@ unsigned notify_get_next(struct notify_app *);
unsigned notify_get_next_bkgd(void);
char *notify_app_txt(void);
void notify_check_next_app(int);
-void notify_check_added(char *, long, char);
+void notify_check_added(char *, time_t, char);
void notify_check_repeated(struct recur_apoint *);
-int notify_same_item(long);
+int notify_same_item(time_t);
int notify_same_recur_item(struct recur_apoint *);
void notify_config_bar(void);
@@ -1018,10 +1018,10 @@ void recur_apoint_llist_init(void);
void recur_event_llist_init(void);
void recur_apoint_llist_free(void);
void recur_event_llist_free(void);
-struct recur_apoint *recur_apoint_new(char *, char *, long, long, char,
- int, int, long, llist_t *);
-struct recur_event *recur_event_new(char *, char *, long, int, int, int,
- long, llist_t *);
+struct recur_apoint *recur_apoint_new(char *, char *, time_t, long, char,
+ int, int, time_t, llist_t *);
+struct recur_event *recur_event_new(char *, char *, time_t, int, int, int,
+ time_t, llist_t *);
char recur_def2char(enum recur_type);
int recur_char2def(char);
struct recur_apoint *recur_apoint_scan(FILE *, struct tm, struct tm,
@@ -1037,22 +1037,22 @@ char *recur_event_tostr(struct recur_event *);
char *recur_event_hash(struct recur_event *);
void recur_event_write(struct recur_event *, FILE *);
void recur_save_data(FILE *);
-unsigned recur_item_find_occurrence(long, long, llist_t *, int,
- int, long, long, time_t *);
-unsigned recur_apoint_find_occurrence(struct recur_apoint *, long, time_t *);
-unsigned recur_event_find_occurrence(struct recur_event *, long, time_t *);
-unsigned recur_item_inday(long, long, llist_t *, int, int, long, long);
-unsigned recur_apoint_inday(struct recur_apoint *, long *);
-unsigned recur_event_inday(struct recur_event *, long *);
-void recur_event_add_exc(struct recur_event *, long);
-void recur_apoint_add_exc(struct recur_apoint *, long);
+unsigned recur_item_find_occurrence(time_t, long, llist_t *, int,
+ int, time_t, time_t, time_t *);
+unsigned recur_apoint_find_occurrence(struct recur_apoint *, time_t, time_t *);
+unsigned recur_event_find_occurrence(struct recur_event *, time_t, time_t *);
+unsigned recur_item_inday(time_t, long, llist_t *, int, int, time_t, time_t);
+unsigned recur_apoint_inday(struct recur_apoint *, time_t *);
+unsigned recur_event_inday(struct recur_event *, time_t *);
+void recur_event_add_exc(struct recur_event *, time_t);
+void recur_apoint_add_exc(struct recur_apoint *, time_t);
void recur_event_erase(struct recur_event *);
void recur_apoint_erase(struct recur_apoint *);
void recur_exc_scan(llist_t *, FILE *);
void recur_apoint_check_next(struct notify_app *, time_t, time_t);
void recur_apoint_switch_notify(struct recur_apoint *);
-void recur_event_paste_item(struct recur_event *, long);
-void recur_apoint_paste_item(struct recur_apoint *, long);
+void recur_event_paste_item(struct recur_event *, time_t);
+void recur_apoint_paste_item(struct recur_apoint *, time_t);
/* sigs.c */
void sigs_init(void);
@@ -1155,24 +1155,24 @@ void erase_window_part(WINDOW *, int, int, int, int);
WINDOW *popup(int, int, int, int, const char *, const char *, int);
void print_in_middle(WINDOW *, int, int, int, const char *);
int is_all_digit(const char *);
-long get_item_time(long);
-int get_item_hour(long);
-int get_item_min(long);
+long get_item_time(time_t);
+int get_item_hour(time_t);
+int get_item_min(time_t);
struct tm date2tm(struct date, unsigned, unsigned);
time_t date2sec(struct date, unsigned, unsigned);
time_t utcdate2sec(struct date, unsigned, unsigned);
int date_cmp_day(time_t, time_t);
-char *date_sec2date_str(long, const char *);
-void date_sec2date_fmt(long, const char *, char *);
+char *date_sec2date_str(time_t, const char *);
+void date_sec2date_fmt(time_t, const char *, char *);
int date_change(struct tm *, int, int);
-long date_sec_change(long, int, int);
-long update_time_in_date(long, unsigned, unsigned);
+time_t date_sec_change(time_t, int, int);
+time_t update_time_in_date(time_t, unsigned, unsigned);
time_t get_sec_date(struct date);
long min2sec(unsigned);
void draw_scrollbar(struct scrollwin *, int);
void item_in_popup(const char *, const char *, const char *, const char *);
time_t get_today(void);
-long now(void);
+time_t now(void);
char *nowstr(void);
void print_bool_option_incolor(WINDOW *, unsigned, int, int);
const char *get_tempdir(void);
@@ -1192,10 +1192,10 @@ int fork_exec(int *, int *, const char *, const char *const *);
int shell_exec(int *, int *, const char *, const char *const *);
int child_wait(int *, int *, int);
void press_any_key(void);
-void print_apoint(const char *, long, struct apoint *);
-void print_event(const char *, long, struct event *);
-void print_recur_apoint(const char *, long, time_t, struct recur_apoint *);
-void print_recur_event(const char *, long, struct recur_event *);
+void print_apoint(const char *, time_t, struct apoint *);
+void print_event(const char *, time_t, struct event *);
+void print_recur_apoint(const char *, time_t, time_t, struct recur_apoint *);
+void print_recur_event(const char *, time_t, struct recur_event *);
void print_todo(const char *, struct todo *);
int vasprintf(char **, const char *, va_list);
int asprintf(char **, const char *, ...);
diff --git a/src/day.c b/src/day.c
index dd93b53..ceded38 100644
--- a/src/day.c
+++ b/src/day.c
@@ -96,7 +96,7 @@ static int day_cmp(struct day_item **pa, struct day_item **pb)
}
/* Add an item to the current day list. */
-static void day_add_item(int type, long start, union aptev_ptr item)
+static void day_add_item(int type, time_t start, union aptev_ptr item)
{
struct day_item *day = mem_malloc(sizeof(struct day_item));
day->type = type;
@@ -188,7 +188,7 @@ int day_item_get_state(struct day_item *day)
}
/* Add an exception to an item. */
-void day_item_add_exc(struct day_item *day, long date)
+void day_item_add_exc(struct day_item *day, time_t date)
{
switch (day->type) {
case RECUR_EVNT:
@@ -234,7 +234,7 @@ void day_item_fork(struct day_item *day_in, struct day_item *day_out)
* dedicated to the selected day.
* Returns the number of events for the selected day.
*/
-static int day_store_events(long date)
+static int day_store_events(time_t date)
{
llist_item_t *i;
union aptev_ptr p;
@@ -258,7 +258,7 @@ static int day_store_events(long date)
* dedicated to the selected day.
* Returns the number of recurrent events for the selected day.
*/
-static int day_store_recur_events(long date)
+static int day_store_recur_events(time_t date)
{
llist_item_t *i;
union aptev_ptr p;
@@ -282,7 +282,7 @@ static int day_store_recur_events(long date)
* structure dedicated to the selected day.
* Returns the number of appointments for the selected day.
*/
-static int day_store_apoints(long date)
+static int day_store_apoints(time_t date)
{
llist_item_t *i;
union aptev_ptr p;
@@ -312,7 +312,7 @@ static int day_store_apoints(long date)
* structure dedicated to the selected day.
* Returns the number of recurrent appointments for the selected day.
*/
-static int day_store_recur_apoints(long date)
+static int day_store_recur_apoints(time_t date)
{
llist_item_t *i;
union aptev_ptr p;
@@ -344,7 +344,7 @@ static int day_store_recur_apoints(long date)
* The number of events and appointments in the current day are also updated.
*/
void
-day_store_items(long date, int include_captions)
+day_store_items(time_t date, int include_captions)
{
unsigned apts, events;
union aptev_ptr p = { NULL };
@@ -394,7 +394,7 @@ void day_process_storage(struct date *slctd_date, unsigned day_changed)
*/
void
day_display_item_date(struct day_item *day, WINDOW *win, int incolor,
- long date, int y, int x)
+ time_t date, int y, int x)
{
char a_st[100], a_end[100];
char ch_recur, ch_notify;
@@ -448,7 +448,7 @@ day_display_item(struct day_item *day, WINDOW *win, int incolor, int width,
}
/* Write the appointments and events for the selected day to stdout. */
-void day_write_stdout(long date, const char *fmt_apt, const char *fmt_rapt,
+void day_write_stdout(time_t date, const char *fmt_apt, const char *fmt_rapt,
const char *fmt_ev, const char *fmt_rev, int *limit)
{
int i;
@@ -576,7 +576,7 @@ unsigned day_chk_busy_slices(struct date day, int slicesno, int *slices)
recur_apoint_inday, i) {
struct recur_apoint *rapt = LLIST_TS_GET_DATA(i);
time_t occurrence;
- long start, end;
+ time_t start, end;
if (!recur_apoint_find_occurrence(rapt, t, &occurrence))
continue;
@@ -609,8 +609,8 @@ unsigned day_chk_busy_slices(struct date day, int slicesno, int *slices)
LLIST_TS_LOCK(&alist_p);
LLIST_TS_FIND_FOREACH(&alist_p, (time_t *)&t, apoint_inday, i) {
struct apoint *apt = LLIST_TS_GET_DATA(i);
- long start = get_item_time(apt->start);
- long end = get_item_time(apt->start + apt->dur);
+ time_t start = get_item_time(apt->start);
+ time_t end = get_item_time(apt->start + apt->dur);
if (apt->start >= t + DAYINSEC)
break;
@@ -639,7 +639,7 @@ unsigned day_chk_busy_slices(struct date day, int slicesno, int *slices)
}
/* Cut an item so it can be pasted somewhere else later. */
-struct day_item *day_cut_item(long date, int item_number)
+struct day_item *day_cut_item(time_t date, int item_number)
{
struct day_item *p = day_get_item(item_number);
@@ -665,7 +665,7 @@ struct day_item *day_cut_item(long date, int item_number)
}
/* Paste a previously cut item. */
-int day_paste_item(struct day_item *p, long date)
+int day_paste_item(struct day_item *p, time_t date)
{
if (!p->type) {
/* No previously cut item. */
diff --git a/src/event.c b/src/event.c
index 65af662..ed170fd 100644
--- a/src/event.c
+++ b/src/event.c
@@ -89,7 +89,7 @@ static int event_cmp(struct event *a, struct event *b)
}
/* Create a new event */
-struct event *event_new(char *mesg, char *note, long day, int id)
+struct event *event_new(char *mesg, char *note, time_t day, int id)
{
struct event *ev;
@@ -105,7 +105,7 @@ struct event *event_new(char *mesg, char *note, long day, int id)
}
/* Check if the event belongs to the selected day */
-unsigned event_inday(struct event *i, long *start)
+unsigned event_inday(struct event *i, time_t *start)
{
return (date_cmp_day(i->day, *start) == 0);
}
@@ -218,7 +218,7 @@ void event_delete(struct event *ev)
LLIST_REMOVE(&eventlist, i);
}
-void event_paste_item(struct event *ev, long date)
+void event_paste_item(struct event *ev, time_t date)
{
ev->day = date;
LLIST_ADD_SORTED(&eventlist, ev, event_cmp);
diff --git a/src/notify.c b/src/notify.c
index 5a44c0b..312be4e 100644
--- a/src/notify.c
+++ b/src/notify.c
@@ -98,7 +98,7 @@ unsigned notify_needs_reminder(void)
* Note: the mutex associated with this structure must be locked by the
* caller!
*/
-void notify_update_app(long start, char state, char *msg)
+void notify_update_app(time_t start, char state, char *msg)
{
notify_free_app();
notify_app.got_app = 1;
@@ -469,7 +469,7 @@ void notify_check_next_app(int force)
}
/* Check if the newly created appointment is to be notified. */
-void notify_check_added(char *mesg, long start, char state)
+void notify_check_added(char *mesg, time_t start, char state)
{
time_t current_time;
int update_notify = 0;
@@ -523,7 +523,7 @@ void notify_check_repeated(struct recur_apoint *i)
notify_update_bar();
}
-int notify_same_item(long time)
+int notify_same_item(time_t time)
{
int same = 0;
diff --git a/src/recur.c b/src/recur.c
index 31f84ae..2a0a9f7 100644
--- a/src/recur.c
+++ b/src/recur.c
@@ -62,7 +62,7 @@ static int exc_cmp_day(struct excp *a, struct excp *b)
return a->st < b->st ? -1 : (a->st == b->st ? 0 : 1);
}
-static void recur_add_exc(llist_t * exc, long day)
+static void recur_add_exc(llist_t * exc, time_t day)
{
struct excp *o = mem_malloc(sizeof(struct excp));
o->st = day;
@@ -206,9 +206,9 @@ static int recur_event_cmp(struct recur_event *a, struct recur_event *b)
}
/* Insert a new recursive appointment in the general linked list */
-struct recur_apoint *recur_apoint_new(char *mesg, char *note, long start,
+struct recur_apoint *recur_apoint_new(char *mesg, char *note, time_t start,
long dur, char state, int type,
- int freq, long until,
+ int freq, time_t until,
llist_t * except)
{
struct recur_apoint *rapt =
@@ -238,8 +238,8 @@ struct recur_apoint *recur_apoint_new(char *mesg, char *note, long start,
}
/* Insert a new recursive event in the general linked list */
-struct recur_event *recur_event_new(char *mesg, char *note, long day,
- int id, int type, int freq, long until,
+struct recur_event *recur_event_new(char *mesg, char *note, time_t day,
+ int id, int type, int freq, time_t until,
llist_t * except)
{
struct recur_event *rev = mem_malloc(sizeof(struct recur_event));
@@ -686,7 +686,7 @@ static long diff_years(struct tm lt_start, struct tm lt_end)
return lt_end.tm_year - lt_start.tm_year;
}
-static int exc_inday(struct excp *exc, long *day_start)
+static int exc_inday(struct excp *exc, time_t *day_start)
{
return (date_cmp_day(exc->st, *day_start) == 0);
}
@@ -701,9 +701,9 @@ static int exc_inday(struct excp *exc, long *day_start)
* calculation of recurrent dates after a turn of years.
*/
unsigned
-recur_item_find_occurrence(long item_start, long item_dur,
+recur_item_find_occurrence(time_t item_start, long item_dur,
llist_t * item_exc, int rpt_type, int rpt_freq,
- long rpt_until, long day_start,
+ time_t rpt_until, time_t day_start,
time_t *occurrence)
{
struct date start_date;
@@ -789,7 +789,7 @@ recur_item_find_occurrence(long item_start, long item_dur,
}
unsigned
-recur_apoint_find_occurrence(struct recur_apoint *rapt, long day_start,
+recur_apoint_find_occurrence(struct recur_apoint *rapt, time_t day_start,
time_t *occurrence)
{
return recur_item_find_occurrence(rapt->start, rapt->dur,
@@ -800,7 +800,7 @@ recur_apoint_find_occurrence(struct recur_apoint *rapt, long day_start,
}
unsigned
-recur_event_find_occurrence(struct recur_event *rev, long day_start,
+recur_event_find_occurrence(struct recur_event *rev, time_t day_start,
time_t *occurrence)
{
return recur_item_find_occurrence(rev->day, DAYINSEC, &rev->exc,
@@ -811,9 +811,9 @@ recur_event_find_occurrence(struct recur_event *rev, long day_start,
/* Check if a recurrent item belongs to the selected day. */
unsigned
-recur_item_inday(long item_start, long item_dur, llist_t * item_exc,
- int rpt_type, int rpt_freq, long rpt_until,
- long day_start)
+recur_item_inday(time_t item_start, long item_dur, llist_t * item_exc,
+ int rpt_type, int rpt_freq, time_t rpt_until,
+ time_t day_start)
{
/* We do not need the (real) start time of the occurrence here, so just
* ignore the buffer. */
@@ -822,14 +822,14 @@ recur_item_inday(long item_start, long item_dur, llist_t * item_exc,
day_start, NULL);
}
-unsigned recur_apoint_inday(struct recur_apoint *rapt, long *day_start)
+unsigned recur_apoint_inday(struct recur_apoint *rapt, time_t *day_start)
{
return recur_item_inday(rapt->start, rapt->dur, &rapt->exc,
rapt->rpt->type, rapt->rpt->freq,
rapt->rpt->until, *day_start);
}
-unsigned recur_event_inday(struct recur_event *rev, long *day_start)
+unsigned recur_event_inday(struct recur_event *rev, time_t *day_start)
{
return recur_item_inday(rev->day, DAYINSEC, &rev->exc,
rev->rpt->type, rev->rpt->freq,
@@ -837,13 +837,13 @@ unsigned recur_event_inday(struct recur_event *rev, long *day_start)
}
/* Add an exception to a recurrent event. */
-void recur_event_add_exc(struct recur_event *rev, long date)
+void recur_event_add_exc(struct recur_event *rev, time_t date)
{
recur_add_exc(&rev->exc, date);
}
/* Add an exception to a recurrent appointment. */
-void recur_apoint_add_exc(struct recur_apoint *rapt, long date)
+void recur_apoint_add_exc(struct recur_apoint *rapt, time_t date)
{
int need_check_notify = 0;
@@ -972,7 +972,7 @@ void recur_apoint_switch_notify(struct recur_apoint *rapt)
LLIST_TS_UNLOCK(&recur_alist_p);
}
-void recur_event_paste_item(struct recur_event *rev, long date)
+void recur_event_paste_item(struct recur_event *rev, time_t date)
{
long time_shift;
llist_item_t *i;
@@ -991,9 +991,9 @@ void recur_event_paste_item(struct recur_event *rev, long date)
LLIST_ADD_SORTED(&recur_elist, rev, recur_event_cmp);
}
-void recur_apoint_paste_item(struct recur_apoint *rapt, long date)
+void recur_apoint_paste_item(struct recur_apoint *rapt, time_t date)
{
- long ostart = rapt->start;
+ time_t ostart = rapt->start;
int days;
llist_item_t *i;
struct tm t;
diff --git a/src/ui-calendar.c b/src/ui-calendar.c
index 407f294..10ae5cb 100644
--- a/src/ui-calendar.c
+++ b/src/ui-calendar.c
@@ -743,7 +743,7 @@ void ui_calendar_move(enum move move, int count)
}
/* Returns the beginning of current year as a long. */
-long ui_calendar_start_of_year(void)
+time_t ui_calendar_start_of_year(void)
{
time_t timer;
struct tm tm;
@@ -757,10 +757,10 @@ long ui_calendar_start_of_year(void)
tm.tm_sec = 0;
timer = mktime(&tm);
- return (long)timer;
+ return timer;
}
-long ui_calendar_end_of_year(void)
+time_t ui_calendar_end_of_year(void)
{
time_t timer;
struct tm tm;
@@ -775,5 +775,5 @@ long ui_calendar_end_of_year(void)
tm.tm_year++;
timer = mktime(&tm);
- return (long)(timer - 1);
+ return (timer - 1);
}
diff --git a/src/ui-day.c b/src/ui-day.c
index 979ecc0..9d76775 100644
--- a/src/ui-day.c
+++ b/src/ui-day.c
@@ -66,7 +66,7 @@ void ui_day_set_selitem(struct day_item *day)
* for validation of the new end time.
* If move = 0, the new end time is calculated by the caller.
*/
-static int day_edit_time(int start, int duration, int move)
+static time_t day_edit_time(time_t start, long duration, int move)
{
const char *msg_time = _("Enter start date [%s] and/or time ([hh:mm] or [hhmm]):");
const char *enter_str = _("Press [Enter] to continue");
@@ -105,9 +105,9 @@ static int day_edit_time(int start, int duration, int move)
* when the new start time is known.
* If move = 1, duration is fixed, but passed on for validation of new end time.
*/
-static void update_start_time(long *start, long *dur, int move)
+static void update_start_time(time_t *start, long *dur, int move)
{
- long newtime;
+ time_t newtime;
const char *msg_wrong_time =
_("Invalid time: start time must come before end time!");
const char *msg_enter = _("Press [Enter] to continue");
@@ -133,7 +133,7 @@ static void update_start_time(long *start, long *dur, int move)
}
/* Request the user to enter a new end time or duration. */
-static void update_duration(long *start, long *dur)
+static void update_duration(time_t *start, long *dur)
{
const char *msg_time =
_("Enter end date (and/or time) or duration ('?' for input formats):");
@@ -144,7 +144,7 @@ static void update_duration(long *start, long *dur)
const char *enter_str = _("Press [Enter] to continue");
const char *fmt_msg_1 = _("Invalid time or duration.");
const char *fmt_msg_2 = _("Invalid date: end time must come after start time.");
- long end;
+ time_t end;
unsigned newdur;
char *timestr, *outstr;
diff --git a/src/utils.c b/src/utils.c
index d380926..5457319 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -358,25 +358,25 @@ int is_all_digit(const char *string)
}
/* Given an item date expressed in seconds, return its start time in seconds. */
-long get_item_time(long date)
+long get_item_time(time_t date)
{
return (long)(get_item_hour(date) * HOURINSEC +
get_item_min(date) * MININSEC);
}
-int get_item_hour(long date)
+int get_item_hour(time_t date)
{
struct tm lt;
- localtime_r((time_t *) & date, &lt);
+ localtime_r(&date, &lt);
return lt.tm_hour;
}
-int get_item_min(long date)
+int get_item_min(time_t date)
{
struct tm lt;
- localtime_r((time_t *) & date, &lt);
+ localtime_r(&date, &lt);
return lt.tm_min;
}
@@ -457,7 +457,7 @@ int date_cmp_day(time_t d1, time_t d2)
}
/* Return a string containing the date, given a date in seconds. */
-char *date_sec2date_str(long sec, const char *datefmt)
+char *date_sec2date_str(time_t sec, const char *datefmt)
{
struct tm lt;
char *datestr = (char *)mem_calloc(BUFSIZ, sizeof(char));
@@ -465,7 +465,7 @@ char *date_sec2date_str(long sec, const char *datefmt)
if (sec == 0) {
strncpy(datestr, "0", BUFSIZ);
} else {
- localtime_r((time_t *) & sec, &lt);
+ localtime_r(&sec, &lt);
strftime(datestr, BUFSIZ, datefmt, &lt);
}
@@ -473,7 +473,7 @@ char *date_sec2date_str(long sec, const char *datefmt)
}
/* Generic function to format date. */
-void date_sec2date_fmt(long sec, const char *fmt, char *datef)
+void date_sec2date_fmt(time_t sec, const char *fmt, char *datef)
{
#if ENABLE_NLS
/* TODO: Find a better way to deal with localization and strftime(). */
@@ -482,7 +482,7 @@ void date_sec2date_fmt(long sec, const char *fmt, char *datef)
#endif
struct tm lt;
- localtime_r((time_t *) & sec, &lt);
+ localtime_r(&sec, &lt);
strftime(datef, BUFSIZ, fmt, &lt);
#if ENABLE_NLS
@@ -514,7 +514,7 @@ int date_change(struct tm *date, int delta_month, int delta_day)
/*
* Used to change date by adding a certain amount of days or months.
*/
-long date_sec_change(long date, int delta_month, int delta_day)
+time_t date_sec_change(time_t date, int delta_month, int delta_day)
{
struct tm lt;
time_t t;
@@ -673,9 +673,9 @@ time_t get_today(void)
}
/* Returns the current time in seconds. */
-long now(void)
+time_t now(void)
{
- return (long)time(NULL);
+ return time(NULL);
}
char *nowstr(void)
@@ -1597,12 +1597,12 @@ static enum format_specifier parse_fs(const char **s, char *extformat)
* Print date to stdout, formatted to be displayed for day.
* The "day" argument may be any time belonging to that day.
*/
-static void print_date(long date, long day, const char *extformat)
+static void print_date(time_t date, time_t day, const char *extformat)
{
char buf[BUFSIZ];
if (!strcmp(extformat, "epoch")) {
- printf("%ld", date);
+ printf("%ld", (long)date);
} else {
time_t day_start = update_time_in_date(day, 0, 0);
time_t day_end = date_sec_change(day_start, 0, 1);
@@ -1697,7 +1697,7 @@ static void print_datediff(long difference, const char *extformat)
}
/* Print a formatted appointment to stdout. */
-static void print_apoint_helper(const char *format, long day,
+static void print_apoint_helper(const char *format, time_t day,
struct apoint *apt, struct recur_apoint *rapt)
{
const char *p;
@@ -1765,7 +1765,7 @@ static void print_apoint_helper(const char *format, long day,
}
/* Print a formatted event to stdout. */
-static void print_event_helper(const char *format, long day, struct event *ev,
+static void print_event_helper(const char *format, time_t day, struct event *ev,
struct recur_event *rev)
{
const char *p;
@@ -1815,20 +1815,20 @@ static void print_event_helper(const char *format, long day, struct event *ev,
}
/* Print a formatted appointment to stdout. */
-void print_apoint(const char *format, long day, struct apoint *apt)
+void print_apoint(const char *format, time_t day, struct apoint *apt)
{
print_apoint_helper(format, day, apt, NULL);
}
/* Print a formatted event to stdout. */
-void print_event(const char *format, long day, struct event *ev)
+void print_event(const char *format, time_t day, struct event *ev)
{
print_event_helper(format, day, ev, NULL);
}
/* Print a formatted recurrent appointment to stdout. */
void
-print_recur_apoint(const char *format, long day, time_t occurrence,
+print_recur_apoint(const char *format, time_t day, time_t occurrence,
struct recur_apoint *rapt)
{
struct apoint apt;
@@ -1842,7 +1842,7 @@ print_recur_apoint(const char *format, long day, time_t occurrence,
}
/* Print a formatted recurrent event to stdout. */
-void print_recur_event(const char *format, long day,
+void print_recur_event(const char *format, time_t day,
struct recur_event *rev)
{
struct event ev;