Use time_t for system time values

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
Lukas Fleischer 2019-01-14 06:01:21 +01:00
parent 51f17fb9c6
commit 03340db72e
9 changed files with 129 additions and 129 deletions

View File

@ -98,7 +98,7 @@ static int apoint_cmp(struct apoint *a, struct apoint *b)
return strcmp(a->mesg, b->mesg); 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) char state)
{ {
struct apoint *apt; struct apoint *apt;
@ -117,14 +117,14 @@ struct apoint *apoint_new(char *mesg, char *note, long start, long dur,
return apt; 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 || return (date_cmp_day(i->start, *start) == 0 ||
(date_cmp_day(i->start, *start) < 0 && (date_cmp_day(i->start, *start) < 0 &&
date_cmp_day(i->start + i->dur - 1, *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; struct tm lt;
time_t t; time_t t;
@ -278,7 +278,7 @@ void apoint_delete(struct apoint *apt)
LLIST_TS_UNLOCK(&alist_p); 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; 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 * 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). * 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; llist_item_t *i;
@ -324,7 +324,7 @@ void apoint_switch_notify(struct apoint *apt)
LLIST_TS_UNLOCK(&alist_p); 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; struct tm t;

View File

@ -335,7 +335,7 @@ struct date {
/* Appointment definition. */ /* Appointment definition. */
struct apoint { 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 */ long dur; /* duration of the appointment in seconds */
#define APOINT_NULL 0x0 #define APOINT_NULL 0x0
@ -350,7 +350,7 @@ struct apoint {
/* Event definition. */ /* Event definition. */
struct event { struct event {
int id; /* event identifier */ int id; /* event identifier */
long day; /* seconds since 1 jan 1970 */ time_t day; /* seconds since 1 jan 1970 */
char *mesg; char *mesg;
char *note; char *note;
}; };
@ -364,7 +364,7 @@ struct todo {
}; };
struct excp { struct excp {
long st; /* beggining of the considered day, in seconds */ time_t st; /* beggining of the considered day, in seconds */
}; };
enum recur_type { enum recur_type {
@ -380,14 +380,14 @@ enum recur_type {
struct rpt { struct rpt {
enum recur_type type; /* repetition type */ enum recur_type type; /* repetition type */
int freq; /* repetition frequency */ int freq; /* repetition frequency */
long until; /* ending date for repeated event */ time_t until; /* ending date for repeated event */
}; };
/* Recurrent appointment definition. */ /* Recurrent appointment definition. */
struct recur_apoint { struct recur_apoint {
struct rpt *rpt; /* information about repetition */ struct rpt *rpt; /* information about repetition */
llist_t exc; /* days when the item should not be repeated */ 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 */ long dur; /* duration of the appointment */
char state; /* 8 bits to store item state */ char state; /* 8 bits to store item state */
char *mesg; /* appointment description */ char *mesg; /* appointment description */
@ -399,7 +399,7 @@ struct recur_event {
struct rpt *rpt; /* information about repetition */ struct rpt *rpt; /* information about repetition */
llist_t exc; /* days when the item should not be repeated */ llist_t exc; /* days when the item should not be repeated */
int id; /* event type */ int id; /* event type */
long day; /* day at which event occurs */ time_t day; /* day at which event occurs */
char *mesg; /* event description */ char *mesg; /* event description */
char *note; /* note attached to event */ char *note; /* note attached to event */
}; };
@ -459,13 +459,13 @@ struct item_filter {
/* Generic item description (to hold appointments, events...). */ /* Generic item description (to hold appointments, events...). */
struct day_item { struct day_item {
enum day_item_type type; enum day_item_type type;
long start; time_t start;
union aptev_ptr item; union aptev_ptr item;
}; };
/* Shared variables for the notification threads. */ /* Shared variables for the notification threads. */
struct notify_app { struct notify_app {
long time; time_t time;
int got_app; int got_app;
char *txt; char *txt;
char state; char state;
@ -742,18 +742,18 @@ struct apoint *apoint_dup(struct apoint *);
void apoint_free(struct apoint *); void apoint_free(struct apoint *);
void apoint_llist_init(void); void apoint_llist_init(void);
void apoint_llist_free(void); void apoint_llist_free(void);
struct apoint *apoint_new(char *, char *, long, long, char); struct apoint *apoint_new(char *, char *, time_t, long, char);
unsigned apoint_inday(struct apoint *, long *); unsigned apoint_inday(struct apoint *, time_t *);
void apoint_sec2str(struct apoint *, long, char *, char *); void apoint_sec2str(struct apoint *, time_t, char *, char *);
char *apoint_tostr(struct apoint *); char *apoint_tostr(struct apoint *);
char *apoint_hash(struct apoint *); char *apoint_hash(struct apoint *);
void apoint_write(struct apoint *, FILE *); void apoint_write(struct apoint *, FILE *);
struct apoint *apoint_scan(FILE *, struct tm, struct tm, char, char *, struct apoint *apoint_scan(FILE *, struct tm, struct tm, char, char *,
struct item_filter *); struct item_filter *);
void apoint_delete(struct apoint *); 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_switch_notify(struct apoint *);
void apoint_paste_item(struct apoint *, long); void apoint_paste_item(struct apoint *, time_t);
/* args.c */ /* args.c */
int parse_args(int, char **); int parse_args(int, char **);
@ -779,8 +779,8 @@ void ui_calendar_update_panel(void);
void ui_calendar_goto_today(void); void ui_calendar_goto_today(void);
void ui_calendar_change_day(int); void ui_calendar_change_day(int);
void ui_calendar_move(enum move, int); void ui_calendar_move(enum move, int);
long ui_calendar_start_of_year(void); time_t ui_calendar_start_of_year(void);
long ui_calendar_end_of_year(void); time_t ui_calendar_end_of_year(void);
/* config.c */ /* config.c */
void config_load(void); void config_load(void);
@ -804,19 +804,19 @@ char *day_item_get_note(struct day_item *);
void day_item_erase_note(struct day_item *); void day_item_erase_note(struct day_item *);
long day_item_get_duration(struct day_item *); long day_item_get_duration(struct day_item *);
int day_item_get_state(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_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_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_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 *); const char *, int *);
void day_popup_item(struct day_item *); void day_popup_item(struct day_item *);
int day_check_if_item(struct date); int day_check_if_item(struct date);
unsigned day_chk_busy_slices(struct date, int, int *); unsigned day_chk_busy_slices(struct date, int, int *);
struct day_item *day_cut_item(long, int); struct day_item *day_cut_item(time_t, int);
int day_paste_item(struct day_item *, long); int day_paste_item(struct day_item *, time_t);
int day_get_position_by_aptev_ptr(union aptev_ptr); int day_get_position_by_aptev_ptr(union aptev_ptr);
int day_get_position(struct day_item *); int day_get_position(struct day_item *);
struct day_item *day_get_item(int); struct day_item *day_get_item(int);
@ -836,14 +836,14 @@ struct event *event_dup(struct event *);
void event_free(struct event *); void event_free(struct event *);
void event_llist_init(void); void event_llist_init(void);
void event_llist_free(void); void event_llist_free(void);
struct event *event_new(char *, char *, long, int); struct event *event_new(char *, char *, time_t, int);
unsigned event_inday(struct event *, long *); unsigned event_inday(struct event *, time_t *);
char *event_tostr(struct event *); char *event_tostr(struct event *);
char *event_hash(struct event *); char *event_hash(struct event *);
void event_write(struct event *, FILE *); void event_write(struct event *, FILE *);
struct event *event_scan(FILE *, struct tm, int, char *, struct item_filter *); struct event *event_scan(FILE *, struct tm, int, char *, struct item_filter *);
void event_delete(struct event *); void event_delete(struct event *);
void event_paste_item(struct event *, long); void event_paste_item(struct event *, time_t);
/* getstring.c */ /* getstring.c */
enum getstr getstring(WINDOW *, char *, int, int, int); enum getstr getstring(WINDOW *, char *, int, int, int);
@ -982,7 +982,7 @@ void note_gc(void);
/* notify.c */ /* notify.c */
int notify_time_left(void); int notify_time_left(void);
unsigned notify_needs_reminder(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); int notify_bar(void);
void notify_init_vars(void); void notify_init_vars(void);
void notify_init_bar(void); void notify_init_bar(void);
@ -996,9 +996,9 @@ unsigned notify_get_next(struct notify_app *);
unsigned notify_get_next_bkgd(void); unsigned notify_get_next_bkgd(void);
char *notify_app_txt(void); char *notify_app_txt(void);
void notify_check_next_app(int); 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 *); 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 *); int notify_same_recur_item(struct recur_apoint *);
void notify_config_bar(void); void notify_config_bar(void);
@ -1018,10 +1018,10 @@ void recur_apoint_llist_init(void);
void recur_event_llist_init(void); void recur_event_llist_init(void);
void recur_apoint_llist_free(void); void recur_apoint_llist_free(void);
void recur_event_llist_free(void); void recur_event_llist_free(void);
struct recur_apoint *recur_apoint_new(char *, char *, long, long, char, struct recur_apoint *recur_apoint_new(char *, char *, time_t, long, char,
int, int, long, llist_t *); int, int, time_t, llist_t *);
struct recur_event *recur_event_new(char *, char *, long, int, int, int, struct recur_event *recur_event_new(char *, char *, time_t, int, int, int,
long, llist_t *); time_t, llist_t *);
char recur_def2char(enum recur_type); char recur_def2char(enum recur_type);
int recur_char2def(char); int recur_char2def(char);
struct recur_apoint *recur_apoint_scan(FILE *, struct tm, struct tm, 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 *); char *recur_event_hash(struct recur_event *);
void recur_event_write(struct recur_event *, FILE *); void recur_event_write(struct recur_event *, FILE *);
void recur_save_data(FILE *); void recur_save_data(FILE *);
unsigned recur_item_find_occurrence(long, long, llist_t *, int, unsigned recur_item_find_occurrence(time_t, long, llist_t *, int,
int, long, long, time_t *); int, time_t, time_t, time_t *);
unsigned recur_apoint_find_occurrence(struct recur_apoint *, long, time_t *); unsigned recur_apoint_find_occurrence(struct recur_apoint *, time_t, time_t *);
unsigned recur_event_find_occurrence(struct recur_event *, long, time_t *); unsigned recur_event_find_occurrence(struct recur_event *, time_t, time_t *);
unsigned recur_item_inday(long, long, llist_t *, int, int, long, long); unsigned recur_item_inday(time_t, long, llist_t *, int, int, time_t, time_t);
unsigned recur_apoint_inday(struct recur_apoint *, long *); unsigned recur_apoint_inday(struct recur_apoint *, time_t *);
unsigned recur_event_inday(struct recur_event *, long *); unsigned recur_event_inday(struct recur_event *, time_t *);
void recur_event_add_exc(struct recur_event *, long); void recur_event_add_exc(struct recur_event *, time_t);
void recur_apoint_add_exc(struct recur_apoint *, long); void recur_apoint_add_exc(struct recur_apoint *, time_t);
void recur_event_erase(struct recur_event *); void recur_event_erase(struct recur_event *);
void recur_apoint_erase(struct recur_apoint *); void recur_apoint_erase(struct recur_apoint *);
void recur_exc_scan(llist_t *, FILE *); void recur_exc_scan(llist_t *, FILE *);
void recur_apoint_check_next(struct notify_app *, time_t, time_t); void recur_apoint_check_next(struct notify_app *, time_t, time_t);
void recur_apoint_switch_notify(struct recur_apoint *); void recur_apoint_switch_notify(struct recur_apoint *);
void recur_event_paste_item(struct recur_event *, long); void recur_event_paste_item(struct recur_event *, time_t);
void recur_apoint_paste_item(struct recur_apoint *, long); void recur_apoint_paste_item(struct recur_apoint *, time_t);
/* sigs.c */ /* sigs.c */
void sigs_init(void); 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); WINDOW *popup(int, int, int, int, const char *, const char *, int);
void print_in_middle(WINDOW *, int, int, int, const char *); void print_in_middle(WINDOW *, int, int, int, const char *);
int is_all_digit(const char *); int is_all_digit(const char *);
long get_item_time(long); long get_item_time(time_t);
int get_item_hour(long); int get_item_hour(time_t);
int get_item_min(long); int get_item_min(time_t);
struct tm date2tm(struct date, unsigned, unsigned); struct tm date2tm(struct date, unsigned, unsigned);
time_t date2sec(struct date, unsigned, unsigned); time_t date2sec(struct date, unsigned, unsigned);
time_t utcdate2sec(struct date, unsigned, unsigned); time_t utcdate2sec(struct date, unsigned, unsigned);
int date_cmp_day(time_t, time_t); int date_cmp_day(time_t, time_t);
char *date_sec2date_str(long, const char *); char *date_sec2date_str(time_t, const char *);
void date_sec2date_fmt(long, const char *, char *); void date_sec2date_fmt(time_t, const char *, char *);
int date_change(struct tm *, int, int); int date_change(struct tm *, int, int);
long date_sec_change(long, int, int); time_t date_sec_change(time_t, int, int);
long update_time_in_date(long, unsigned, unsigned); time_t update_time_in_date(time_t, unsigned, unsigned);
time_t get_sec_date(struct date); time_t get_sec_date(struct date);
long min2sec(unsigned); long min2sec(unsigned);
void draw_scrollbar(struct scrollwin *, int); void draw_scrollbar(struct scrollwin *, int);
void item_in_popup(const char *, const char *, const char *, const char *); void item_in_popup(const char *, const char *, const char *, const char *);
time_t get_today(void); time_t get_today(void);
long now(void); time_t now(void);
char *nowstr(void); char *nowstr(void);
void print_bool_option_incolor(WINDOW *, unsigned, int, int); void print_bool_option_incolor(WINDOW *, unsigned, int, int);
const char *get_tempdir(void); 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 shell_exec(int *, int *, const char *, const char *const *);
int child_wait(int *, int *, int); int child_wait(int *, int *, int);
void press_any_key(void); void press_any_key(void);
void print_apoint(const char *, long, struct apoint *); void print_apoint(const char *, time_t, struct apoint *);
void print_event(const char *, long, struct event *); void print_event(const char *, time_t, struct event *);
void print_recur_apoint(const char *, long, time_t, struct recur_apoint *); void print_recur_apoint(const char *, time_t, time_t, struct recur_apoint *);
void print_recur_event(const char *, long, struct recur_event *); void print_recur_event(const char *, time_t, struct recur_event *);
void print_todo(const char *, struct todo *); void print_todo(const char *, struct todo *);
int vasprintf(char **, const char *, va_list); int vasprintf(char **, const char *, va_list);
int asprintf(char **, const char *, ...); int asprintf(char **, const char *, ...);

View File

@ -96,7 +96,7 @@ static int day_cmp(struct day_item **pa, struct day_item **pb)
} }
/* Add an item to the current day list. */ /* 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)); struct day_item *day = mem_malloc(sizeof(struct day_item));
day->type = type; day->type = type;
@ -188,7 +188,7 @@ int day_item_get_state(struct day_item *day)
} }
/* Add an exception to an item. */ /* 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) { switch (day->type) {
case RECUR_EVNT: 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. * dedicated to the selected day.
* Returns the number of events for 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; llist_item_t *i;
union aptev_ptr p; union aptev_ptr p;
@ -258,7 +258,7 @@ static int day_store_events(long date)
* dedicated to the selected day. * dedicated to the selected day.
* Returns the number of recurrent events for 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; llist_item_t *i;
union aptev_ptr p; union aptev_ptr p;
@ -282,7 +282,7 @@ static int day_store_recur_events(long date)
* structure dedicated to the selected day. * structure dedicated to the selected day.
* Returns the number of appointments for 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; llist_item_t *i;
union aptev_ptr p; union aptev_ptr p;
@ -312,7 +312,7 @@ static int day_store_apoints(long date)
* structure dedicated to the selected day. * structure dedicated to the selected day.
* Returns the number of recurrent appointments for 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; llist_item_t *i;
union aptev_ptr p; 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. * The number of events and appointments in the current day are also updated.
*/ */
void void
day_store_items(long date, int include_captions) day_store_items(time_t date, int include_captions)
{ {
unsigned apts, events; unsigned apts, events;
union aptev_ptr p = { NULL }; union aptev_ptr p = { NULL };
@ -394,7 +394,7 @@ void day_process_storage(struct date *slctd_date, unsigned day_changed)
*/ */
void void
day_display_item_date(struct day_item *day, WINDOW *win, int incolor, 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 a_st[100], a_end[100];
char ch_recur, ch_notify; 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. */ /* 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) const char *fmt_ev, const char *fmt_rev, int *limit)
{ {
int i; int i;
@ -576,7 +576,7 @@ unsigned day_chk_busy_slices(struct date day, int slicesno, int *slices)
recur_apoint_inday, i) { recur_apoint_inday, i) {
struct recur_apoint *rapt = LLIST_TS_GET_DATA(i); struct recur_apoint *rapt = LLIST_TS_GET_DATA(i);
time_t occurrence; time_t occurrence;
long start, end; time_t start, end;
if (!recur_apoint_find_occurrence(rapt, t, &occurrence)) if (!recur_apoint_find_occurrence(rapt, t, &occurrence))
continue; continue;
@ -609,8 +609,8 @@ unsigned day_chk_busy_slices(struct date day, int slicesno, int *slices)
LLIST_TS_LOCK(&alist_p); LLIST_TS_LOCK(&alist_p);
LLIST_TS_FIND_FOREACH(&alist_p, (time_t *)&t, apoint_inday, i) { LLIST_TS_FIND_FOREACH(&alist_p, (time_t *)&t, apoint_inday, i) {
struct apoint *apt = LLIST_TS_GET_DATA(i); struct apoint *apt = LLIST_TS_GET_DATA(i);
long start = get_item_time(apt->start); time_t start = get_item_time(apt->start);
long end = get_item_time(apt->start + apt->dur); time_t end = get_item_time(apt->start + apt->dur);
if (apt->start >= t + DAYINSEC) if (apt->start >= t + DAYINSEC)
break; 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. */ /* 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); 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. */ /* 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) { if (!p->type) {
/* No previously cut item. */ /* No previously cut item. */

View File

@ -89,7 +89,7 @@ static int event_cmp(struct event *a, struct event *b)
} }
/* Create a new event */ /* 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; 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 */ /* 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); return (date_cmp_day(i->day, *start) == 0);
} }
@ -218,7 +218,7 @@ void event_delete(struct event *ev)
LLIST_REMOVE(&eventlist, i); 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; ev->day = date;
LLIST_ADD_SORTED(&eventlist, ev, event_cmp); LLIST_ADD_SORTED(&eventlist, ev, event_cmp);

View File

@ -98,7 +98,7 @@ unsigned notify_needs_reminder(void)
* Note: the mutex associated with this structure must be locked by the * Note: the mutex associated with this structure must be locked by the
* caller! * 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_free_app();
notify_app.got_app = 1; 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. */ /* 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; time_t current_time;
int update_notify = 0; int update_notify = 0;
@ -523,7 +523,7 @@ void notify_check_repeated(struct recur_apoint *i)
notify_update_bar(); notify_update_bar();
} }
int notify_same_item(long time) int notify_same_item(time_t time)
{ {
int same = 0; int same = 0;

View File

@ -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); 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)); struct excp *o = mem_malloc(sizeof(struct excp));
o->st = day; 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 */ /* 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, long dur, char state, int type,
int freq, long until, int freq, time_t until,
llist_t * except) llist_t * except)
{ {
struct recur_apoint *rapt = 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 */ /* Insert a new recursive event in the general linked list */
struct recur_event *recur_event_new(char *mesg, char *note, long day, struct recur_event *recur_event_new(char *mesg, char *note, time_t day,
int id, int type, int freq, long until, int id, int type, int freq, time_t until,
llist_t * except) llist_t * except)
{ {
struct recur_event *rev = mem_malloc(sizeof(struct recur_event)); 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; 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); 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. * calculation of recurrent dates after a turn of years.
*/ */
unsigned 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, 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) time_t *occurrence)
{ {
struct date start_date; struct date start_date;
@ -789,7 +789,7 @@ recur_item_find_occurrence(long item_start, long item_dur,
} }
unsigned 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) time_t *occurrence)
{ {
return recur_item_find_occurrence(rapt->start, rapt->dur, 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 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) time_t *occurrence)
{ {
return recur_item_find_occurrence(rev->day, DAYINSEC, &rev->exc, 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. */ /* Check if a recurrent item belongs to the selected day. */
unsigned unsigned
recur_item_inday(long item_start, long item_dur, llist_t * item_exc, recur_item_inday(time_t item_start, long item_dur, llist_t * item_exc,
int rpt_type, int rpt_freq, long rpt_until, int rpt_type, int rpt_freq, time_t rpt_until,
long day_start) time_t day_start)
{ {
/* We do not need the (real) start time of the occurrence here, so just /* We do not need the (real) start time of the occurrence here, so just
* ignore the buffer. */ * ignore the buffer. */
@ -822,14 +822,14 @@ recur_item_inday(long item_start, long item_dur, llist_t * item_exc,
day_start, NULL); 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, return recur_item_inday(rapt->start, rapt->dur, &rapt->exc,
rapt->rpt->type, rapt->rpt->freq, rapt->rpt->type, rapt->rpt->freq,
rapt->rpt->until, *day_start); 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, return recur_item_inday(rev->day, DAYINSEC, &rev->exc,
rev->rpt->type, rev->rpt->freq, 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. */ /* 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); recur_add_exc(&rev->exc, date);
} }
/* Add an exception to a recurrent appointment. */ /* 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; int need_check_notify = 0;
@ -972,7 +972,7 @@ void recur_apoint_switch_notify(struct recur_apoint *rapt)
LLIST_TS_UNLOCK(&recur_alist_p); 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; long time_shift;
llist_item_t *i; 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); 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; int days;
llist_item_t *i; llist_item_t *i;
struct tm t; struct tm t;

View File

@ -743,7 +743,7 @@ void ui_calendar_move(enum move move, int count)
} }
/* Returns the beginning of current year as a long. */ /* 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; time_t timer;
struct tm tm; struct tm tm;
@ -757,10 +757,10 @@ long ui_calendar_start_of_year(void)
tm.tm_sec = 0; tm.tm_sec = 0;
timer = mktime(&tm); 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; time_t timer;
struct tm tm; struct tm tm;
@ -775,5 +775,5 @@ long ui_calendar_end_of_year(void)
tm.tm_year++; tm.tm_year++;
timer = mktime(&tm); timer = mktime(&tm);
return (long)(timer - 1); return (timer - 1);
} }

View File

@ -66,7 +66,7 @@ void ui_day_set_selitem(struct day_item *day)
* for validation of the new end time. * for validation of the new end time.
* If move = 0, the new end time is calculated by the caller. * 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 *msg_time = _("Enter start date [%s] and/or time ([hh:mm] or [hhmm]):");
const char *enter_str = _("Press [Enter] to continue"); 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. * when the new start time is known.
* If move = 1, duration is fixed, but passed on for validation of new end time. * 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 = const char *msg_wrong_time =
_("Invalid time: start time must come before end time!"); _("Invalid time: start time must come before end time!");
const char *msg_enter = _("Press [Enter] to continue"); 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. */ /* 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 = const char *msg_time =
_("Enter end date (and/or time) or duration ('?' for input formats):"); _("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 *enter_str = _("Press [Enter] to continue");
const char *fmt_msg_1 = _("Invalid time or duration."); const char *fmt_msg_1 = _("Invalid time or duration.");
const char *fmt_msg_2 = _("Invalid date: end time must come after start time."); const char *fmt_msg_2 = _("Invalid date: end time must come after start time.");
long end; time_t end;
unsigned newdur; unsigned newdur;
char *timestr, *outstr; char *timestr, *outstr;

View File

@ -358,25 +358,25 @@ int is_all_digit(const char *string)
} }
/* Given an item date expressed in seconds, return its start time in seconds. */ /* 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 + return (long)(get_item_hour(date) * HOURINSEC +
get_item_min(date) * MININSEC); get_item_min(date) * MININSEC);
} }
int get_item_hour(long date) int get_item_hour(time_t date)
{ {
struct tm lt; struct tm lt;
localtime_r((time_t *) & date, &lt); localtime_r(&date, &lt);
return lt.tm_hour; return lt.tm_hour;
} }
int get_item_min(long date) int get_item_min(time_t date)
{ {
struct tm lt; struct tm lt;
localtime_r((time_t *) & date, &lt); localtime_r(&date, &lt);
return lt.tm_min; 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. */ /* 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; struct tm lt;
char *datestr = (char *)mem_calloc(BUFSIZ, sizeof(char)); char *datestr = (char *)mem_calloc(BUFSIZ, sizeof(char));
@ -465,7 +465,7 @@ char *date_sec2date_str(long sec, const char *datefmt)
if (sec == 0) { if (sec == 0) {
strncpy(datestr, "0", BUFSIZ); strncpy(datestr, "0", BUFSIZ);
} else { } else {
localtime_r((time_t *) & sec, &lt); localtime_r(&sec, &lt);
strftime(datestr, BUFSIZ, datefmt, &lt); strftime(datestr, BUFSIZ, datefmt, &lt);
} }
@ -473,7 +473,7 @@ char *date_sec2date_str(long sec, const char *datefmt)
} }
/* Generic function to format date. */ /* 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 #if ENABLE_NLS
/* TODO: Find a better way to deal with localization and strftime(). */ /* 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 #endif
struct tm lt; struct tm lt;
localtime_r((time_t *) & sec, &lt); localtime_r(&sec, &lt);
strftime(datef, BUFSIZ, fmt, &lt); strftime(datef, BUFSIZ, fmt, &lt);
#if ENABLE_NLS #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. * 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; struct tm lt;
time_t t; time_t t;
@ -673,9 +673,9 @@ time_t get_today(void)
} }
/* Returns the current time in seconds. */ /* Returns the current time in seconds. */
long now(void) time_t now(void)
{ {
return (long)time(NULL); return time(NULL);
} }
char *nowstr(void) 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. * Print date to stdout, formatted to be displayed for day.
* The "day" argument may be any time belonging to that 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]; char buf[BUFSIZ];
if (!strcmp(extformat, "epoch")) { if (!strcmp(extformat, "epoch")) {
printf("%ld", date); printf("%ld", (long)date);
} else { } else {
time_t day_start = update_time_in_date(day, 0, 0); time_t day_start = update_time_in_date(day, 0, 0);
time_t day_end = date_sec_change(day_start, 0, 1); 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. */ /* 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) struct apoint *apt, struct recur_apoint *rapt)
{ {
const char *p; const char *p;
@ -1765,7 +1765,7 @@ static void print_apoint_helper(const char *format, long day,
} }
/* Print a formatted event to stdout. */ /* 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) struct recur_event *rev)
{ {
const char *p; 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. */ /* 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_apoint_helper(format, day, apt, NULL);
} }
/* Print a formatted event to stdout. */ /* 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_event_helper(format, day, ev, NULL);
} }
/* Print a formatted recurrent appointment to stdout. */ /* Print a formatted recurrent appointment to stdout. */
void 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 recur_apoint *rapt)
{ {
struct apoint apt; 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. */ /* 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 recur_event *rev)
{ {
struct event ev; struct event ev;