date2sec() and get_sec_date() prototypes updated to take into account date_t type, today() renamed to get_today()
This commit is contained in:
parent
a18b025933
commit
95671e19c5
57
src/utils.c
57
src/utils.c
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: utils.c,v 1.28 2007/05/06 13:27:51 culot Exp $ */
|
/* $calcurse: utils.c,v 1.29 2007/07/01 17:50:53 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -442,8 +442,8 @@ status_bar(int which_pan, int nc_bar, int nl_bar)
|
|||||||
wnoutrefresh(swin);
|
wnoutrefresh(swin);
|
||||||
}
|
}
|
||||||
|
|
||||||
long date2sec(unsigned year, unsigned month, unsigned day, unsigned hour,
|
long
|
||||||
unsigned min)
|
date2sec(date_t day, unsigned hour, unsigned min)
|
||||||
{
|
{
|
||||||
struct tm start, *lt;
|
struct tm start, *lt;
|
||||||
time_t tstart, t;
|
time_t tstart, t;
|
||||||
@ -452,9 +452,9 @@ long date2sec(unsigned year, unsigned month, unsigned day, unsigned hour,
|
|||||||
lt = localtime(&t);
|
lt = localtime(&t);
|
||||||
start = *lt;
|
start = *lt;
|
||||||
|
|
||||||
start.tm_mon = month;
|
start.tm_mon = day.mm;
|
||||||
start.tm_mday = day;
|
start.tm_mday = day.dd;
|
||||||
start.tm_year = year;
|
start.tm_year = day.yyyy;
|
||||||
start.tm_hour = hour;
|
start.tm_hour = hour;
|
||||||
start.tm_min = min;
|
start.tm_min = min;
|
||||||
start.tm_sec = 0;
|
start.tm_sec = 0;
|
||||||
@ -463,11 +463,14 @@ long date2sec(unsigned year, unsigned month, unsigned day, unsigned hour,
|
|||||||
start.tm_mon--;
|
start.tm_mon--;
|
||||||
tstart = mktime(&start);
|
tstart = mktime(&start);
|
||||||
if (tstart == -1) {
|
if (tstart == -1) {
|
||||||
fputs(_("FATAL ERROR in date2sec: failure in mktime\n"), stderr);
|
fputs(_("FATAL ERROR in date2sec: failure in mktime\n"),
|
||||||
fprintf(stderr, "%u %u %u %u %u\n", year, month, day, hour, min);
|
stderr);
|
||||||
|
fprintf(stderr, "%u %u %u %u %u\n", day.yyyy, day.mm, day.dd,
|
||||||
|
hour, min);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
return tstart;
|
|
||||||
|
return (tstart);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return a string containing the hour of a given date in seconds. */
|
/* Return a string containing the hour of a given date in seconds. */
|
||||||
@ -571,25 +574,26 @@ long update_time_in_date(long date, unsigned hr, unsigned mn)
|
|||||||
* If no date is entered, current date is chosen.
|
* If no date is entered, current date is chosen.
|
||||||
*/
|
*/
|
||||||
long
|
long
|
||||||
get_sec_date(int year, int month, int day)
|
get_sec_date(date_t date)
|
||||||
{
|
{
|
||||||
struct tm *ptrtime;
|
struct tm *ptrtime;
|
||||||
time_t timer;
|
time_t timer;
|
||||||
long long_date;
|
long long_date;
|
||||||
char current_day[3], current_month[3] ,current_year[5];
|
char current_day[] = "dd ";
|
||||||
|
char current_month[] = "mm ";
|
||||||
|
char current_year[] = "yyyy ";
|
||||||
|
|
||||||
if (year == 0 && month == 0 && day == 0) {
|
if (date.yyyy == 0 && date.mm == 0 && date.dd == 0) {
|
||||||
timer = time(NULL);
|
timer = time(NULL);
|
||||||
ptrtime = localtime(&timer);
|
ptrtime = localtime(&timer);
|
||||||
strftime(current_day, 3, "%d", ptrtime);
|
strftime(current_day, strlen(current_day), "%d", ptrtime);
|
||||||
strftime(current_month, 3, "%m", ptrtime);
|
strftime(current_month, strlen(current_month), "%m", ptrtime);
|
||||||
strftime(current_year, 5, "%Y", ptrtime);
|
strftime(current_year, strlen(current_year), "%Y", ptrtime);
|
||||||
month = atoi(current_month);
|
date.mm = atoi(current_month);
|
||||||
day = atoi(current_day);
|
date.dd = atoi(current_day);
|
||||||
year = atoi(current_year);
|
date.yyyy = atoi(current_year);
|
||||||
|
|
||||||
}
|
}
|
||||||
long_date = date2sec(year, month, day, 0, 0);
|
long_date = date2sec(date, 0, 0);
|
||||||
return long_date;
|
return long_date;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -767,19 +771,20 @@ void other_status_page(int panel)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Returns the beginning of current day in seconds from 1900. */
|
/* Returns the beginning of current day in seconds from 1900. */
|
||||||
long today(void)
|
long
|
||||||
|
get_today(void)
|
||||||
{
|
{
|
||||||
struct tm *lt;
|
struct tm *lt;
|
||||||
time_t current_time;
|
time_t current_time;
|
||||||
long current_day;
|
long current_day;
|
||||||
int year, month, day;
|
date_t day;
|
||||||
|
|
||||||
current_time = time(NULL);
|
current_time = time(NULL);
|
||||||
lt = localtime(¤t_time);
|
lt = localtime(¤t_time);
|
||||||
month = lt->tm_mon + 1;
|
day.mm = lt->tm_mon + 1;
|
||||||
day = lt->tm_mday;
|
day.dd = lt->tm_mday;
|
||||||
year = lt->tm_year + 1900;
|
day.yyyy = lt->tm_year + 1900;
|
||||||
current_day = date2sec(year, month, day, 0, 0);
|
current_day = date2sec(day, 0, 0);
|
||||||
|
|
||||||
return current_day;
|
return current_day;
|
||||||
}
|
}
|
||||||
|
73
src/utils.h
73
src/utils.h
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: utils.h,v 1.17 2007/03/24 23:12:35 culot Exp $ */
|
/* $calcurse: utils.h,v 1.18 2007/07/01 17:50:53 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -27,6 +27,8 @@
|
|||||||
#ifndef CALCURSE_UTILS_H
|
#ifndef CALCURSE_UTILS_H
|
||||||
#define CALCURSE_UTILS_H
|
#define CALCURSE_UTILS_H
|
||||||
|
|
||||||
|
#include "calendar.h"
|
||||||
|
|
||||||
#define MAX(x,y) ((x)>(y)?(x):(y))
|
#define MAX(x,y) ((x)>(y)?(x):(y))
|
||||||
#define MIN(x,y) ((x)<(y)?(x):(y))
|
#define MIN(x,y) ((x)<(y)?(x):(y))
|
||||||
|
|
||||||
@ -50,42 +52,37 @@ typedef struct { /* structure defining a keybinding */
|
|||||||
char *label;
|
char *label;
|
||||||
} binding_t;
|
} binding_t;
|
||||||
|
|
||||||
void status_mesg(char *mesg_line1, char *mesg_line2);
|
void status_mesg(char *, char *);
|
||||||
void erase_window_part(WINDOW *win, int first_col, int first_row,
|
void erase_window_part(WINDOW *, int, int, int, int);
|
||||||
int last_col, int last_row);
|
WINDOW *popup(int, int, int, int, char *);
|
||||||
WINDOW *popup(int pop_row, int pop_col, int pop_y, int pop_x, char *pop_lab);
|
void print_in_middle(WINDOW *, int, int, int, char *);
|
||||||
void print_in_middle(WINDOW *win, int starty, int startx, int width, char *string);
|
void del_char(int, char *);
|
||||||
void del_char(int pos, char *str);
|
char *add_char(int, int, char *);
|
||||||
char *add_char(int pos, int ch, char *str);
|
void showcursor(WINDOW *, int, int, char *, int, int);
|
||||||
void showcursor(WINDOW *win, int y, int pos, char *str, int l, int offset);
|
void showstring(WINDOW *, int, int, char *, int, int);
|
||||||
void showstring(WINDOW *win, int y, int x, char *str, int len, int pos);
|
int getstring(WINDOW *, char *, int, int, int);
|
||||||
int getstring(WINDOW *win, char *str, int l, int x, int y);
|
int updatestring(WINDOW *, char **, int, int);
|
||||||
int updatestring(WINDOW *win, char **str, int x, int y);
|
int is_all_digit(char *);
|
||||||
int is_all_digit(char *string);
|
void border_color(WINDOW *);
|
||||||
void border_color(WINDOW *window);
|
void border_nocolor(WINDOW *);
|
||||||
void border_nocolor(WINDOW *window);
|
void status_bar(int, int, int);
|
||||||
void status_bar(int which_pan, int nc_bar, int nl_bar);
|
long date2sec(date_t, unsigned, unsigned);
|
||||||
long date2sec(unsigned year, unsigned month, unsigned day, unsigned hour,
|
char *date_sec2hour_str(long);
|
||||||
unsigned min);
|
char *date_sec2date_str(long);
|
||||||
char *date_sec2hour_str(long sec);
|
void date_sec2ical_date(long, char *);
|
||||||
char *date_sec2date_str(long sec);
|
void date_sec2ical_datetime(long, char *);
|
||||||
void date_sec2ical_date(long sec, char *ical_date);
|
long update_time_in_date(long, unsigned, unsigned);
|
||||||
void date_sec2ical_datetime(long sec, char *ical_date);
|
long get_sec_date(date_t);
|
||||||
long update_time_in_date(long date, unsigned hr, unsigned min);
|
long min2sec(unsigned);
|
||||||
long get_sec_date(int year, int month, int day);
|
int check_time(char *);
|
||||||
long min2sec(unsigned minutes);
|
void draw_scrollbar(WINDOW *, int, int, int, int, int, bool);
|
||||||
int check_time(char *string);
|
void item_in_popup(char *, char *, char *, char *);
|
||||||
void draw_scrollbar(WINDOW *win, int y, int x, int length,
|
void win_show(WINDOW *, char *);
|
||||||
int bar_top, int bar_bottom, bool hilt);
|
void display_item(WINDOW *, int, char *, int, int, int, int);
|
||||||
void item_in_popup(char *saved_a_start, char *saved_a_end, char *msg,
|
void reset_status_page(void);
|
||||||
char *pop_title);
|
void other_status_page(int);
|
||||||
void win_show(WINDOW * win, char *label);
|
long get_today(void);
|
||||||
void display_item(WINDOW *win, int incolor, char *msg, int recur,
|
long now(void);
|
||||||
int len, int y, int x);
|
char *mycpy(const char *);
|
||||||
void reset_status_page(void);
|
|
||||||
void other_status_page(int panel);
|
|
||||||
long today(void);
|
|
||||||
long now(void);
|
|
||||||
char *mycpy(const char *src);
|
|
||||||
|
|
||||||
#endif /* CALCURSE_UTILS_H */
|
#endif /* CALCURSE_UTILS_H */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user