Tony's patch concerning date format configuration imported
This commit is contained in:
parent
0f6374d787
commit
0c281d2c1e
@ -1,3 +1,8 @@
|
|||||||
|
09 Apr 2008:
|
||||||
|
Tony's patch concerning date format configuration imported, many
|
||||||
|
thanks to him
|
||||||
|
TODO list updated
|
||||||
|
|
||||||
05 Apr 2008:
|
05 Apr 2008:
|
||||||
'-N' flag added, which allows the display of note contents in
|
'-N' flag added, which allows the display of note contents in
|
||||||
non-interactive mode (many thanks to Erik Saule for submiting
|
non-interactive mode (many thanks to Erik Saule for submiting
|
||||||
|
2
TODO
2
TODO
@ -21,8 +21,6 @@ High
|
|||||||
Average
|
Average
|
||||||
-------
|
-------
|
||||||
o Improve the '-d' option by adding more date formats
|
o Improve the '-d' option by adding more date formats
|
||||||
o Accept dates entered in other formats such as d/m/yyyy or d/m/yy,
|
|
||||||
make the date format user configurable
|
|
||||||
o Make keys user configurable
|
o Make keys user configurable
|
||||||
o Add searching capabilities with support for regex
|
o Add searching capabilities with support for regex
|
||||||
|
|
||||||
|
47
src/args.c
47
src/args.c
@ -1,8 +1,8 @@
|
|||||||
/* $calcurse: args.c,v 1.30 2008/04/05 14:55:59 culot Exp $ */
|
/* $calcurse: args.c,v 1.31 2008/04/09 20:38:29 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
* Copyright (c) 2004-2007 Frederic Culot
|
* Copyright (c) 2004-2008 Frederic Culot
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -230,7 +230,7 @@ next_arg(void)
|
|||||||
* Print the date on stdout.
|
* Print the date on stdout.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
arg_print_date(long date)
|
arg_print_date(long date, conf_t *conf)
|
||||||
{
|
{
|
||||||
char date_str[BUFSIZ];
|
char date_str[BUFSIZ];
|
||||||
time_t t;
|
time_t t;
|
||||||
@ -238,8 +238,7 @@ arg_print_date(long date)
|
|||||||
|
|
||||||
t = date;
|
t = date;
|
||||||
lt = localtime(&t);
|
lt = localtime(&t);
|
||||||
snprintf(date_str, BUFSIZ, "%02u/%02u/%04u",
|
strftime(date_str, BUFSIZ, conf->output_datefmt, lt);
|
||||||
lt->tm_mon+1, lt->tm_mday, 1900+lt->tm_year);
|
|
||||||
fputs(date_str,stdout);
|
fputs(date_str,stdout);
|
||||||
fputs(":\n",stdout);
|
fputs(":\n",stdout);
|
||||||
}
|
}
|
||||||
@ -250,7 +249,7 @@ arg_print_date(long date)
|
|||||||
* If there is also no date given, current date is considered.
|
* If there is also no date given, current date is considered.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
app_arg(int add_line, date_t *day, long date, int print_note)
|
app_arg(int add_line, date_t *day, long date, int print_note, conf_t *conf)
|
||||||
{
|
{
|
||||||
struct recur_event_s *re;
|
struct recur_event_s *re;
|
||||||
struct event_s *j;
|
struct event_s *j;
|
||||||
@ -281,7 +280,7 @@ app_arg(int add_line, date_t *day, long date, int print_note)
|
|||||||
add_line = 0;
|
add_line = 0;
|
||||||
}
|
}
|
||||||
if (print_date) {
|
if (print_date) {
|
||||||
arg_print_date(today);
|
arg_print_date(today, conf);
|
||||||
print_date = false;
|
print_date = false;
|
||||||
}
|
}
|
||||||
fputs(" * ", stdout);
|
fputs(" * ", stdout);
|
||||||
@ -299,7 +298,7 @@ app_arg(int add_line, date_t *day, long date, int print_note)
|
|||||||
add_line = 0;
|
add_line = 0;
|
||||||
}
|
}
|
||||||
if (print_date) {
|
if (print_date) {
|
||||||
arg_print_date(today);
|
arg_print_date(today, conf);
|
||||||
print_date = false;
|
print_date = false;
|
||||||
}
|
}
|
||||||
fputs(" * ", stdout);
|
fputs(" * ", stdout);
|
||||||
@ -321,7 +320,7 @@ app_arg(int add_line, date_t *day, long date, int print_note)
|
|||||||
add_line = 0;
|
add_line = 0;
|
||||||
}
|
}
|
||||||
if (print_date) {
|
if (print_date) {
|
||||||
arg_print_date(today);
|
arg_print_date(today, conf);
|
||||||
print_date = false;
|
print_date = false;
|
||||||
}
|
}
|
||||||
apoint_sec2str(apoint_recur_s2apoint_s(ra),
|
apoint_sec2str(apoint_recur_s2apoint_s(ra),
|
||||||
@ -349,7 +348,7 @@ app_arg(int add_line, date_t *day, long date, int print_note)
|
|||||||
add_line = 0;
|
add_line = 0;
|
||||||
}
|
}
|
||||||
if (print_date) {
|
if (print_date) {
|
||||||
arg_print_date(today);
|
arg_print_date(today, conf);
|
||||||
print_date = false;
|
print_date = false;
|
||||||
}
|
}
|
||||||
apoint_sec2str(i, APPT, today, apoint_start_time,
|
apoint_sec2str(i, APPT, today, apoint_start_time,
|
||||||
@ -375,13 +374,12 @@ app_arg(int add_line, date_t *day, long date, int print_note)
|
|||||||
* days.
|
* days.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
date_arg(char *ddate, int add_line, int print_note)
|
date_arg(char *ddate, int add_line, int print_note, conf_t *conf)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
date_t day;
|
date_t day;
|
||||||
int numdays = 0, num_digit = 0;
|
int numdays = 0, num_digit = 0;
|
||||||
int arg_len = 0, app_found = 0;
|
int arg_len = 0, app_found = 0;
|
||||||
int date_valid = 0;
|
|
||||||
static struct tm t;
|
static struct tm t;
|
||||||
time_t timer;
|
time_t timer;
|
||||||
|
|
||||||
@ -410,22 +408,23 @@ date_arg(char *ddate, int add_line, int print_note)
|
|||||||
day.dd = t.tm_mday;
|
day.dd = t.tm_mday;
|
||||||
day.mm = t.tm_mon + 1;
|
day.mm = t.tm_mon + 1;
|
||||||
day.yyyy = t.tm_year + 1900;
|
day.yyyy = t.tm_year + 1900;
|
||||||
app_found = app_arg(add_line, &day, 0, print_note);
|
app_found = app_arg(add_line, &day, 0, print_note, conf);
|
||||||
if (app_found)
|
if (app_found)
|
||||||
add_line = 1;
|
add_line = 1;
|
||||||
t.tm_mday++;
|
t.tm_mday++;
|
||||||
mktime(&t);
|
mktime(&t);
|
||||||
}
|
}
|
||||||
} else { /* a date was entered */
|
} else { /* a date was entered */
|
||||||
date_valid = check_date(ddate);
|
if (parse_date(ddate, conf->input_datefmt,
|
||||||
if (date_valid) {
|
&day.yyyy, &day.mm, &day.dd)) {
|
||||||
sscanf(ddate, "%d / %d / %d", &day.mm, &day.dd, &day.yyyy);
|
app_found = app_arg(add_line, &day, 0, print_note, conf);
|
||||||
app_found = app_arg(add_line, &day, 0, print_note);
|
|
||||||
} else {
|
} else {
|
||||||
fputs(_("Argument to the '-d' flag is not valid\n"),
|
fputs(_("Argument to the '-d' flag is not valid\n"),
|
||||||
stdout);
|
stdout);
|
||||||
fputs(_("Possible argument formats are : 'mm/dd/yyyy' or 'n'\n"),
|
char outstr[BUFSIZ];
|
||||||
stdout);
|
snprintf(outstr, BUFSIZ, "Possible argument format are: '%s' or 'n'\n",
|
||||||
|
DATEFMT_DESC(conf->input_datefmt));
|
||||||
|
fputs(_(outstr), stdout);
|
||||||
fputs(_("\nFor more information, type '?' from within Calcurse, or read the manpage.\n"),
|
fputs(_("\nFor more information, type '?' from within Calcurse, or read the manpage.\n"),
|
||||||
stdout);
|
stdout);
|
||||||
fputs
|
fputs
|
||||||
@ -575,12 +574,18 @@ parse_args(int argc, char **argv, conf_t *conf)
|
|||||||
non_interactive = 1;
|
non_interactive = 1;
|
||||||
}
|
}
|
||||||
if (dflag) {
|
if (dflag) {
|
||||||
date_arg(ddate, add_line, Nflag);
|
notify_init_vars();
|
||||||
|
vars_init(conf);
|
||||||
|
custom_load_conf(conf, 0);
|
||||||
|
date_arg(ddate, add_line, Nflag, conf);
|
||||||
non_interactive = 1;
|
non_interactive = 1;
|
||||||
} else if (aflag) {
|
} else if (aflag) {
|
||||||
date_t day;
|
date_t day;
|
||||||
day.dd = day.mm = day.yyyy = 0;
|
day.dd = day.mm = day.yyyy = 0;
|
||||||
app_found = app_arg(add_line, &day, 0, Nflag);
|
notify_init_vars();
|
||||||
|
vars_init(conf);
|
||||||
|
custom_load_conf(conf, 0);
|
||||||
|
app_found = app_arg(add_line, &day, 0, Nflag, conf);
|
||||||
non_interactive = 1;
|
non_interactive = 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: calcurse.c,v 1.60 2008/01/13 12:40:45 culot Exp $ */
|
/* $calcurse: calcurse.c,v 1.61 2008/04/09 20:38:29 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -220,7 +220,7 @@ main(int argc, char **argv)
|
|||||||
case 'g': /* Goto function */
|
case 'g': /* Goto function */
|
||||||
erase_status_bar();
|
erase_status_bar();
|
||||||
calendar_set_current_date();
|
calendar_set_current_date();
|
||||||
calendar_change_day();
|
calendar_change_day(conf.input_datefmt);
|
||||||
do_storage = true;
|
do_storage = true;
|
||||||
day_changed = true;
|
day_changed = true;
|
||||||
break;
|
break;
|
||||||
@ -305,7 +305,7 @@ main(int argc, char **argv)
|
|||||||
case 'E':
|
case 'E':
|
||||||
case 'e': /* Edit an existing item */
|
case 'e': /* Edit an existing item */
|
||||||
if (wins_slctd() == APP && apoint_hilt() != 0)
|
if (wins_slctd() == APP && apoint_hilt() != 0)
|
||||||
day_edit_item();
|
day_edit_item(&conf);
|
||||||
else if (wins_slctd() == TOD && todo_hilt() != 0)
|
else if (wins_slctd() == TOD && todo_hilt() != 0)
|
||||||
todo_edit_item();
|
todo_edit_item();
|
||||||
do_storage = true;
|
do_storage = true;
|
||||||
@ -324,7 +324,7 @@ main(int argc, char **argv)
|
|||||||
case 'R':
|
case 'R':
|
||||||
case 'r':
|
case 'r':
|
||||||
if (wins_slctd() == APP && apoint_hilt() != 0)
|
if (wins_slctd() == APP && apoint_hilt() != 0)
|
||||||
recur_repeat_item();
|
recur_repeat_item(&conf);
|
||||||
do_storage = true;
|
do_storage = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/* $calcurse: calendar.c,v 1.13 2007/12/10 18:59:48 culot Exp $ */
|
/* $calcurse: calendar.c,v 1.14 2008/04/09 20:38:29 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
* Copyright (c) 2004-2007 Frederic Culot
|
* Copyright (c) 2004-2008 Frederic Culot
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -332,10 +332,11 @@ calendar_update_panel(WINDOW *cwin)
|
|||||||
* with the newly selected date.
|
* with the newly selected date.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
calendar_change_day(void)
|
calendar_change_day(int datefmt)
|
||||||
{
|
{
|
||||||
#define LDAY 11
|
#define LDAY 11
|
||||||
char selected_day[LDAY] = "";
|
char selected_day[LDAY] = "";
|
||||||
|
char outstr[BUFSIZ];
|
||||||
date_t today;
|
date_t today;
|
||||||
int dday, dmonth, dyear;
|
int dday, dmonth, dyear;
|
||||||
int wrong_day = 1;
|
int wrong_day = 1;
|
||||||
@ -343,10 +344,12 @@ calendar_change_day(void)
|
|||||||
_("The day you entered is not valid (should be between 01/01/1902 and 12/31/2037)");
|
_("The day you entered is not valid (should be between 01/01/1902 and 12/31/2037)");
|
||||||
char *mesg_line2 = _("Press [ENTER] to continue");
|
char *mesg_line2 = _("Press [ENTER] to continue");
|
||||||
char *request_date =
|
char *request_date =
|
||||||
_("Enter the day to go to [ENTER for today] : mm/dd/yyyy");
|
"Enter the day to go to [ENTER for today] : %s";
|
||||||
|
|
||||||
while (wrong_day) {
|
while (wrong_day) {
|
||||||
status_mesg(request_date, "");
|
snprintf(outstr, BUFSIZ, request_date,
|
||||||
|
DATEFMT_DESC(datefmt));
|
||||||
|
status_mesg(_(outstr), "");
|
||||||
if (getstring(win[STA].p, selected_day, LDAY, 0, 1) ==
|
if (getstring(win[STA].p, selected_day, LDAY, 0, 1) ==
|
||||||
GETSTRING_ESC)
|
GETSTRING_ESC)
|
||||||
return;
|
return;
|
||||||
@ -364,24 +367,15 @@ calendar_change_day(void)
|
|||||||
|
|
||||||
wrong_day = 1;
|
wrong_day = 1;
|
||||||
|
|
||||||
} else {
|
} else if (parse_date(selected_day, datefmt,
|
||||||
|
&dyear, &dmonth, &dday)) {
|
||||||
|
|
||||||
sscanf(selected_day, "%u/%u/%u",
|
|
||||||
&dmonth, &dday, &dyear);
|
|
||||||
wrong_day = 0;
|
wrong_day = 0;
|
||||||
|
|
||||||
/* basic check on entered date */
|
|
||||||
if ((dday <= 0) || (dday >= 32) ||
|
|
||||||
(dmonth <= 0) || (dmonth >= 13) ||
|
|
||||||
(dyear <= 1901) || (dyear >= 2038))
|
|
||||||
wrong_day = 1;
|
|
||||||
|
|
||||||
/* go to chosen day */
|
/* go to chosen day */
|
||||||
if (wrong_day != 1) {
|
slctd_day.dd = dday;
|
||||||
slctd_day.dd = dday;
|
slctd_day.mm = dmonth;
|
||||||
slctd_day.mm = dmonth;
|
slctd_day.yyyy = dyear;
|
||||||
slctd_day.yyyy = dyear;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wrong_day) {
|
if (wrong_day) {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/* $calcurse: calendar.h,v 1.8 2007/12/10 19:00:45 culot Exp $ */
|
/* $calcurse: calendar.h,v 1.9 2008/04/09 20:38:29 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
* Copyright (c) 2004-2007 Frederic Culot
|
* Copyright (c) 2004-2008 Frederic Culot
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -79,7 +79,7 @@ void calendar_init_slctd_day(void);
|
|||||||
date_t *calendar_get_slctd_day(void);
|
date_t *calendar_get_slctd_day(void);
|
||||||
long calendar_get_slctd_day_sec(void);
|
long calendar_get_slctd_day_sec(void);
|
||||||
void calendar_update_panel(WINDOW *);
|
void calendar_update_panel(WINDOW *);
|
||||||
void calendar_change_day(void);
|
void calendar_change_day(int datefmt);
|
||||||
void calendar_move(move_t);
|
void calendar_move(move_t);
|
||||||
char *calendar_get_pom(time_t);
|
char *calendar_get_pom(time_t);
|
||||||
|
|
||||||
|
61
src/custom.c
61
src/custom.c
@ -1,8 +1,8 @@
|
|||||||
/* $calcurse: custom.c,v 1.18 2008/02/16 13:14:04 culot Exp $ */
|
/* $calcurse: custom.c,v 1.19 2008/04/09 20:38:29 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
* Copyright (c) 2004-2007 Frederic Culot
|
* Copyright (c) 2004-2008 Frederic Culot
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -285,7 +285,18 @@ custom_load_conf(conf_t *conf, int background)
|
|||||||
strncpy(nbar->cmd, e_conf, strlen(e_conf) + 1);
|
strncpy(nbar->cmd, e_conf, strlen(e_conf) + 1);
|
||||||
var = 0;
|
var = 0;
|
||||||
break;
|
break;
|
||||||
default:
|
case CUSTOM_CONF_OUTPUTDATEFMT:
|
||||||
|
if (e_conf[0] != '\0')
|
||||||
|
strncpy(conf->output_datefmt, e_conf, strlen(e_conf) + 1);
|
||||||
|
var = 0;
|
||||||
|
break;
|
||||||
|
case CUSTOM_CONF_INPUTDATEFMT:
|
||||||
|
conf->input_datefmt = atoi(e_conf);
|
||||||
|
if (conf->input_datefmt < 1 || conf->input_datefmt > 3)
|
||||||
|
conf->input_datefmt = 1;
|
||||||
|
var = 0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
fputs(_("FATAL ERROR in custom_load_conf: "
|
fputs(_("FATAL ERROR in custom_load_conf: "
|
||||||
"configuration variable unknown.\n"), stderr);
|
"configuration variable unknown.\n"), stderr);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
@ -318,6 +329,10 @@ custom_load_conf(conf_t *conf, int background)
|
|||||||
var = CUSTOM_CONF_NOTIFYBARWARNING;
|
var = CUSTOM_CONF_NOTIFYBARWARNING;
|
||||||
else if (strncmp(e_conf, "notify-bar_command=", 19) ==0)
|
else if (strncmp(e_conf, "notify-bar_command=", 19) ==0)
|
||||||
var = CUSTOM_CONF_NOTIFYBARCOMMAND;
|
var = CUSTOM_CONF_NOTIFYBARCOMMAND;
|
||||||
|
else if (strncmp(e_conf, "output_datefmt=", 12) ==0)
|
||||||
|
var = CUSTOM_CONF_OUTPUTDATEFMT;
|
||||||
|
else if (strncmp(e_conf, "input_datefmt=", 12) ==0)
|
||||||
|
var = CUSTOM_CONF_INPUTDATEFMT;
|
||||||
}
|
}
|
||||||
fclose(data_file);
|
fclose(data_file);
|
||||||
pthread_mutex_unlock(&nbar->mutex);
|
pthread_mutex_unlock(&nbar->mutex);
|
||||||
@ -675,6 +690,8 @@ custom_print_general_options(WINDOW *optwin, conf_t *conf)
|
|||||||
char *option4 = _("skip_system_dialogs = ");
|
char *option4 = _("skip_system_dialogs = ");
|
||||||
char *option5 = _("skip_progress_bar = ");
|
char *option5 = _("skip_progress_bar = ");
|
||||||
char *option6 = _("week_begins_on_monday = ");
|
char *option6 = _("week_begins_on_monday = ");
|
||||||
|
char *option7 = _("output_datefmt = ");
|
||||||
|
char *option8 = _("input_datefmt = ");
|
||||||
|
|
||||||
x_pos = 3;
|
x_pos = 3;
|
||||||
y_pos = 3;
|
y_pos = 3;
|
||||||
@ -715,6 +732,22 @@ custom_print_general_options(WINDOW *optwin, conf_t *conf)
|
|||||||
mvwprintw(optwin, y_pos + 16, x_pos,
|
mvwprintw(optwin, y_pos + 16, x_pos,
|
||||||
_("(if set to YES, monday is the first day of the week, else it is sunday)"));
|
_("(if set to YES, monday is the first day of the week, else it is sunday)"));
|
||||||
|
|
||||||
|
mvwprintw(optwin, y_pos + 18, x_pos, "[7] %s ", option7);
|
||||||
|
custom_apply_attr(optwin, ATTR_HIGHEST);
|
||||||
|
mvwprintw(optwin, y_pos + 18, x_pos + 4 + strlen(option7), "%s",
|
||||||
|
conf->output_datefmt);
|
||||||
|
custom_remove_attr(optwin, ATTR_HIGHEST);
|
||||||
|
mvwprintw(optwin, y_pos + 19, x_pos,
|
||||||
|
_("(Format of the date to be displayed in non-interactive mode)"));
|
||||||
|
|
||||||
|
mvwprintw(optwin, y_pos + 21, x_pos, "[8] %s ", option8);
|
||||||
|
custom_apply_attr(optwin, ATTR_HIGHEST);
|
||||||
|
mvwprintw(optwin, y_pos + 21, x_pos + 4 + strlen(option7), "%d",
|
||||||
|
conf->input_datefmt);
|
||||||
|
custom_remove_attr(optwin, ATTR_HIGHEST);
|
||||||
|
mvwprintw(optwin, y_pos + 22, x_pos,
|
||||||
|
_("(Format to be used when entering a date: 1-mm/dd/yyyy, 2-dd/mm/yyyy, 3-yyyy/mm/dd)"));
|
||||||
|
|
||||||
wmove(win[STA].p, 1, 0);
|
wmove(win[STA].p, 1, 0);
|
||||||
wnoutrefresh(optwin);
|
wnoutrefresh(optwin);
|
||||||
doupdate();
|
doupdate();
|
||||||
@ -726,8 +759,13 @@ custom_general_config(conf_t *conf)
|
|||||||
{
|
{
|
||||||
window_t conf_win;
|
window_t conf_win;
|
||||||
char *number_str = _("Enter an option number to change its value [Q to quit] ");
|
char *number_str = _("Enter an option number to change its value [Q to quit] ");
|
||||||
|
char *output_datefmt_str =
|
||||||
|
_("Enter the date format (see 'man 3 strftime' for possible formats) ");
|
||||||
|
char *input_datefmt_str =
|
||||||
|
_("Enter the date format (1-mm/dd/yyyy, 2-dd/mm/yyyy, 3-yyyy/mm/dd) ");
|
||||||
int ch;
|
int ch;
|
||||||
char label[BUFSIZ];
|
char label[BUFSIZ];
|
||||||
|
char *buf = (char *) malloc(BUFSIZ);
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
snprintf(label, BUFSIZ, _("CalCurse %s | general options"), VERSION);
|
snprintf(label, BUFSIZ, _("CalCurse %s | general options"), VERSION);
|
||||||
@ -772,9 +810,26 @@ custom_general_config(conf_t *conf)
|
|||||||
case '6':
|
case '6':
|
||||||
calendar_change_first_day_of_week();
|
calendar_change_first_day_of_week();
|
||||||
break;
|
break;
|
||||||
|
case '7':
|
||||||
|
status_mesg(output_datefmt_str, "");
|
||||||
|
strncpy(buf, conf->output_datefmt, strlen(conf->output_datefmt) + 1);
|
||||||
|
if (updatestring(win[STA].p, &buf, 0, 1) == 0) {
|
||||||
|
strncpy(conf->output_datefmt, buf, strlen(buf) + 1);
|
||||||
|
}
|
||||||
|
status_mesg(number_str, "");
|
||||||
|
break;
|
||||||
|
case '8':
|
||||||
|
status_mesg(input_datefmt_str, "");
|
||||||
|
if (updatestring(win[STA].p, &buf, 0, 1) == 0) {
|
||||||
|
int val = atoi(buf);
|
||||||
|
if (val >= 1 && val <= 3) conf->input_datefmt = val;
|
||||||
|
}
|
||||||
|
status_mesg(number_str, "");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
status_mesg(number_str, "");
|
status_mesg(number_str, "");
|
||||||
custom_print_general_options(conf_win.p, conf);
|
custom_print_general_options(conf_win.p, conf);
|
||||||
}
|
}
|
||||||
|
free(buf);
|
||||||
delwin(conf_win.p);
|
delwin(conf_win.p);
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/* $calcurse: custom.h,v 1.10 2007/10/21 13:41:29 culot Exp $ */
|
/* $calcurse: custom.h,v 1.11 2008/04/09 20:38:29 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
* Copyright (c) 2004-2007 Frederic Culot
|
* Copyright (c) 2004-2008 Frederic Culot
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -59,6 +59,8 @@ enum { /* Configuration variables */
|
|||||||
CUSTOM_CONF_NOTIFYBARCLOCK,
|
CUSTOM_CONF_NOTIFYBARCLOCK,
|
||||||
CUSTOM_CONF_NOTIFYBARWARNING,
|
CUSTOM_CONF_NOTIFYBARWARNING,
|
||||||
CUSTOM_CONF_NOTIFYBARCOMMAND,
|
CUSTOM_CONF_NOTIFYBARCOMMAND,
|
||||||
|
CUSTOM_CONF_OUTPUTDATEFMT,
|
||||||
|
CUSTOM_CONF_INPUTDATEFMT,
|
||||||
CUSTOM_CONF_VARIABLES
|
CUSTOM_CONF_VARIABLES
|
||||||
};
|
};
|
||||||
|
|
||||||
|
34
src/day.c
34
src/day.c
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: day.c,v 1.34 2008/01/20 10:45:38 culot Exp $ */
|
/* $calcurse: day.c,v 1.35 2008/04/09 20:38:29 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -564,11 +564,12 @@ update_desc(char **desc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_rept(struct rpt_s **rpt, const long start)
|
update_rept(struct rpt_s **rpt, const long start, conf_t *conf)
|
||||||
{
|
{
|
||||||
const int SINGLECHAR = 2;
|
const int SINGLECHAR = 2;
|
||||||
int ch, cancel, newfreq, date_entered, valid_date;
|
int ch, cancel, newfreq, date_entered;
|
||||||
long newuntil;
|
long newuntil;
|
||||||
|
char outstr[BUFSIZ];
|
||||||
char *typstr, *freqstr, *timstr;
|
char *typstr, *freqstr, *timstr;
|
||||||
char *msg_rpt_type =
|
char *msg_rpt_type =
|
||||||
_("Enter the new repetition type: (D)aily, (W)eekly, "
|
_("Enter the new repetition type: (D)aily, (W)eekly, "
|
||||||
@ -578,8 +579,8 @@ update_rept(struct rpt_s **rpt, const long start)
|
|||||||
char *msg_wrong_time =
|
char *msg_wrong_time =
|
||||||
_("Invalid time: start time must be before end time!");
|
_("Invalid time: start time must be before end time!");
|
||||||
char *msg_wrong_date = _("The entered date is not valid.");
|
char *msg_wrong_date = _("The entered date is not valid.");
|
||||||
char *msg_fmts = _("Possible formats are [mm/dd/yyyy] or '0' "
|
char *msg_fmts = "Possible formats are [%s] or '0' "
|
||||||
"for an endless repetetition");
|
"for an endless repetetition";
|
||||||
char *msg_enter = _("Press [Enter] to continue");
|
char *msg_enter = _("Press [Enter] to continue");
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@ -615,9 +616,10 @@ update_rept(struct rpt_s **rpt, const long start)
|
|||||||
} while (newfreq == 0);
|
} while (newfreq == 0);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
status_mesg(_("Enter the new ending date: [mm/dd/yyyy] or '0'"),
|
snprintf(outstr, BUFSIZ, "Enter the new ending date: [%s] or '0'",
|
||||||
"");
|
DATEFMT_DESC(conf->input_datefmt));
|
||||||
timstr = date_sec2date_str((*rpt)->until);
|
status_mesg(_(outstr), "");
|
||||||
|
timstr = date_sec2date_str((*rpt)->until, DATEFMT(conf->input_datefmt));
|
||||||
cancel = updatestring(win[STA].p, &timstr, 0, 1);
|
cancel = updatestring(win[STA].p, &timstr, 0, 1);
|
||||||
if (cancel) {
|
if (cancel) {
|
||||||
free(timstr);
|
free(timstr);
|
||||||
@ -632,10 +634,8 @@ update_rept(struct rpt_s **rpt, const long start)
|
|||||||
date_t new_date;
|
date_t new_date;
|
||||||
int newmonth, newday, newyear;
|
int newmonth, newday, newyear;
|
||||||
|
|
||||||
valid_date = check_date(timstr);
|
if (parse_date(timstr, conf->input_datefmt,
|
||||||
if (valid_date) {
|
&newyear, &newmonth, &newday)) {
|
||||||
sscanf(timstr, "%d / %d / %d",
|
|
||||||
&newmonth, &newday, &newyear);
|
|
||||||
t = start;
|
t = start;
|
||||||
lt = localtime(&t);
|
lt = localtime(&t);
|
||||||
new_date.dd = newday;
|
new_date.dd = newday;
|
||||||
@ -650,7 +650,9 @@ update_rept(struct rpt_s **rpt, const long start)
|
|||||||
} else
|
} else
|
||||||
date_entered = 1;
|
date_entered = 1;
|
||||||
} else {
|
} else {
|
||||||
status_mesg(msg_wrong_date, msg_fmts);
|
snprintf(outstr, BUFSIZ, msg_fmts,
|
||||||
|
DATEFMT_DESC(conf->input_datefmt));
|
||||||
|
status_mesg(msg_wrong_date, _(outstr));
|
||||||
wgetch(win[STA].p);
|
wgetch(win[STA].p);
|
||||||
date_entered = 0;
|
date_entered = 0;
|
||||||
}
|
}
|
||||||
@ -665,7 +667,7 @@ update_rept(struct rpt_s **rpt, const long start)
|
|||||||
|
|
||||||
/* Edit an already existing item. */
|
/* Edit an already existing item. */
|
||||||
void
|
void
|
||||||
day_edit_item(void)
|
day_edit_item(conf_t *conf)
|
||||||
{
|
{
|
||||||
#define STRT '1'
|
#define STRT '1'
|
||||||
#define END '2'
|
#define END '2'
|
||||||
@ -698,7 +700,7 @@ day_edit_item(void)
|
|||||||
update_desc(&re->mesg);
|
update_desc(&re->mesg);
|
||||||
break;
|
break;
|
||||||
case '2':
|
case '2':
|
||||||
update_rept(&re->rpt, re->day);
|
update_rept(&re->rpt, re->day, conf);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
@ -727,7 +729,7 @@ day_edit_item(void)
|
|||||||
update_desc(&ra->mesg);
|
update_desc(&ra->mesg);
|
||||||
break;
|
break;
|
||||||
case REPT:
|
case REPT:
|
||||||
update_rept(&ra->rpt, ra->start);
|
update_rept(&ra->rpt, ra->start, conf);
|
||||||
break;
|
break;
|
||||||
case ESCAPE:
|
case ESCAPE:
|
||||||
return;
|
return;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: day.h,v 1.17 2008/01/20 10:45:38 culot Exp $ */
|
/* $calcurse: day.h,v 1.18 2008/04/09 20:38:29 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -27,6 +27,7 @@
|
|||||||
#ifndef CALCURSE_DAY_H
|
#ifndef CALCURSE_DAY_H
|
||||||
#define CALCURSE_DAY_H
|
#define CALCURSE_DAY_H
|
||||||
|
|
||||||
|
#include "vars.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "calendar.h"
|
#include "calendar.h"
|
||||||
|
|
||||||
@ -66,7 +67,7 @@ day_items_nb_t *day_process_storage(date_t *, bool, day_items_nb_t *);
|
|||||||
void day_write_pad(long, int, int, int);
|
void day_write_pad(long, int, int, int);
|
||||||
void day_popup_item(void);
|
void day_popup_item(void);
|
||||||
int day_check_if_item(date_t);
|
int day_check_if_item(date_t);
|
||||||
void day_edit_item(void);
|
void day_edit_item(conf_t *);
|
||||||
int day_erase_item(long, int, erase_flag_e);
|
int day_erase_item(long, int, erase_flag_e);
|
||||||
struct day_item_s *day_get_item(int);
|
struct day_item_s *day_get_item(int);
|
||||||
int day_item_nb(long, int, int);
|
int day_item_nb(long, int, int);
|
||||||
|
12
src/io.c
12
src/io.c
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: io.c,v 1.27 2008/01/20 10:45:38 culot Exp $ */
|
/* $calcurse: io.c,v 1.28 2008/04/09 20:38:29 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -486,6 +486,16 @@ io_save_cal(conf_t *conf)
|
|||||||
fprintf(data_file, "notify-bar_command=\n");
|
fprintf(data_file, "notify-bar_command=\n");
|
||||||
fprintf(data_file, "%s\n", nbar->cmd);
|
fprintf(data_file, "%s\n", nbar->cmd);
|
||||||
|
|
||||||
|
fprintf(data_file,
|
||||||
|
"\n# Format of the date to be displayed in non-interactive mode :\n");
|
||||||
|
fprintf(data_file, "output_datefmt=\n");
|
||||||
|
fprintf(data_file, "%s\n", conf->output_datefmt);
|
||||||
|
|
||||||
|
fprintf(data_file,
|
||||||
|
"\n# Format to be used when entering a date (1-mm/dd/yyyy, 2-dd/mm/yyyy, 3-yyyy/mm/dd) :\n");
|
||||||
|
fprintf(data_file, "input_datefmt=\n");
|
||||||
|
fprintf(data_file, "%d\n", conf->input_datefmt);
|
||||||
|
|
||||||
pthread_mutex_unlock(&nbar->mutex);
|
pthread_mutex_unlock(&nbar->mutex);
|
||||||
|
|
||||||
fclose(data_file);
|
fclose(data_file);
|
||||||
|
28
src/recur.c
28
src/recur.c
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: recur.c,v 1.33 2008/01/20 10:45:39 culot Exp $ */
|
/* $calcurse: recur.c,v 1.34 2008/04/09 20:38:29 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -601,14 +601,15 @@ recur_apoint_erase(long start, unsigned num, unsigned delete_whole,
|
|||||||
* and then delete the selected item to recreate it as a recurrent one
|
* and then delete the selected item to recreate it as a recurrent one
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
recur_repeat_item(void)
|
recur_repeat_item(conf_t *conf)
|
||||||
{
|
{
|
||||||
struct tm *lt;
|
struct tm *lt;
|
||||||
time_t t;
|
time_t t;
|
||||||
int ch = 0;
|
int ch = 0;
|
||||||
int valid_date = 0, date_entered = 0;
|
int date_entered = 0;
|
||||||
int year = 0, month = 0, day = 0;
|
int year = 0, month = 0, day = 0;
|
||||||
date_t until_date;
|
date_t until_date;
|
||||||
|
char outstr[BUFSIZ];
|
||||||
char user_input[BUFSIZ] = "";
|
char user_input[BUFSIZ] = "";
|
||||||
char *mesg_type_1 =
|
char *mesg_type_1 =
|
||||||
_("Enter the repetition type: (D)aily, (W)eekly, (M)onthly, (Y)early");
|
_("Enter the repetition type: (D)aily, (W)eekly, (M)onthly, (Y)early");
|
||||||
@ -618,10 +619,10 @@ recur_repeat_item(void)
|
|||||||
char *mesg_wrong_freq =
|
char *mesg_wrong_freq =
|
||||||
_("The frequence you entered is not valid.");
|
_("The frequence you entered is not valid.");
|
||||||
char *mesg_until_1 =
|
char *mesg_until_1 =
|
||||||
_("Enter the ending date: [mm/dd/yyyy] or '0' for an endless repetition");
|
_("Enter the ending date: [%s] or '0' for an endless repetition");
|
||||||
char *mesg_wrong_1 = _("The entered date is not valid.");
|
char *mesg_wrong_1 = _("The entered date is not valid.");
|
||||||
char *mesg_wrong_2 =
|
char *mesg_wrong_2 =
|
||||||
_("Possible formats are [mm/dd/yyyy] or '0' for an endless repetetition");
|
_("Possible formats are [%s] or '0' for an endless repetetition");
|
||||||
char *wrong_type_1 = _("This item is already a repeated one.");
|
char *wrong_type_1 = _("This item is already a repeated one.");
|
||||||
char *wrong_type_2 = _("Press [ENTER] to continue.");
|
char *wrong_type_2 = _("Press [ENTER] to continue.");
|
||||||
char *mesg_older =
|
char *mesg_older =
|
||||||
@ -669,18 +670,18 @@ recur_repeat_item(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (!date_entered) {
|
while (!date_entered) {
|
||||||
status_mesg(mesg_until_1, "");
|
snprintf(outstr, BUFSIZ, mesg_until_1,
|
||||||
if (getstring(win[STA].p, user_input, 11, 0, 1) ==
|
DATEFMT_DESC(conf->input_datefmt));
|
||||||
|
status_mesg(_(outstr), "");
|
||||||
|
if (getstring(win[STA].p, user_input, BUFSIZ, 0, 1) ==
|
||||||
GETSTRING_VALID) {
|
GETSTRING_VALID) {
|
||||||
if (strlen(user_input) == 1 &&
|
if (strlen(user_input) == 1 &&
|
||||||
strncmp(user_input, "0", 1) == 0 ) {
|
strncmp(user_input, "0", 1) == 0 ) {
|
||||||
until = 0;
|
until = 0;
|
||||||
date_entered = 1;
|
date_entered = 1;
|
||||||
} else {
|
} else {
|
||||||
valid_date = check_date(user_input);
|
if (parse_date(user_input, conf->input_datefmt,
|
||||||
if (valid_date) {
|
&year, &month, &day)) {
|
||||||
sscanf(user_input, "%d / %d / %d",
|
|
||||||
&month, &day, &year);
|
|
||||||
t = p->start; lt = localtime(&t);
|
t = p->start; lt = localtime(&t);
|
||||||
until_date.dd = day;
|
until_date.dd = day;
|
||||||
until_date.mm = month;
|
until_date.mm = month;
|
||||||
@ -696,7 +697,10 @@ recur_repeat_item(void)
|
|||||||
date_entered = 1;
|
date_entered = 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
status_mesg(mesg_wrong_1, mesg_wrong_2);
|
snprintf(outstr, BUFSIZ, mesg_wrong_2,
|
||||||
|
DATEFMT_DESC(conf->input_datefmt));
|
||||||
|
status_mesg(mesg_wrong_1, _(outstr));
|
||||||
|
wgetch(win[STA].p);
|
||||||
date_entered = 0;
|
date_entered = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: recur.h,v 1.17 2008/01/20 10:45:39 culot Exp $ */
|
/* $calcurse: recur.h,v 1.18 2008/04/09 20:38:29 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -90,7 +90,7 @@ void recur_event_erase(long, unsigned, unsigned,
|
|||||||
erase_flag_e);
|
erase_flag_e);
|
||||||
void recur_apoint_erase(long, unsigned, unsigned,
|
void recur_apoint_erase(long, unsigned, unsigned,
|
||||||
erase_flag_e);
|
erase_flag_e);
|
||||||
void recur_repeat_item(void);
|
void recur_repeat_item(conf_t *);
|
||||||
struct days_s *recur_exc_scan(FILE *);
|
struct days_s *recur_exc_scan(FILE *);
|
||||||
struct notify_app_s *recur_apoint_check_next(struct notify_app_s *,
|
struct notify_app_s *recur_apoint_check_next(struct notify_app_s *,
|
||||||
long, long);
|
long, long);
|
||||||
|
92
src/utils.c
92
src/utils.c
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: utils.c,v 1.43 2008/02/11 21:26:01 culot Exp $ */
|
/* $calcurse: utils.c,v 1.44 2008/04/09 20:38:29 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -512,22 +512,20 @@ char *date_sec2hour_str(long sec)
|
|||||||
|
|
||||||
/* Return a string containing the date, given a date in seconds. */
|
/* Return a string containing the date, given a date in seconds. */
|
||||||
char *
|
char *
|
||||||
date_sec2date_str(long sec)
|
date_sec2date_str(long sec, char *datefmt)
|
||||||
{
|
{
|
||||||
const int DATELEN = 11;
|
|
||||||
struct tm *lt;
|
struct tm *lt;
|
||||||
time_t t;
|
time_t t;
|
||||||
char *datestr;
|
char *datestr;
|
||||||
|
|
||||||
datestr = (char *)malloc(sizeof(char) * DATELEN);
|
datestr = (char *)malloc(sizeof(char) * BUFSIZ);
|
||||||
|
|
||||||
if (sec == 0)
|
if (sec == 0)
|
||||||
snprintf(datestr, DATELEN, "0");
|
snprintf(datestr, BUFSIZ, "0");
|
||||||
else {
|
else {
|
||||||
t = sec;
|
t = sec;
|
||||||
lt = localtime(&t);
|
lt = localtime(&t);
|
||||||
snprintf(datestr, DATELEN, "%02u/%02u/%04u", lt->tm_mon + 1,
|
strftime(datestr, BUFSIZ, datefmt, lt);
|
||||||
lt->tm_mday, lt->tm_year + 1900);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (datestr);
|
return (datestr);
|
||||||
@ -616,43 +614,6 @@ get_sec_date(date_t date)
|
|||||||
return long_date;
|
return long_date;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Check if the entered date is of a valid format.
|
|
||||||
* First check the format by itself, and then check the
|
|
||||||
* numbers correctness.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
check_date(char *date)
|
|
||||||
{
|
|
||||||
int ok = 0;
|
|
||||||
char month[3] = "";
|
|
||||||
char day[3] = "";
|
|
||||||
char year[5] = "";
|
|
||||||
if (
|
|
||||||
(strlen(date) == 10) &
|
|
||||||
(isdigit(date[0]) != 0) &
|
|
||||||
(isdigit(date[1]) != 0) &
|
|
||||||
(date[2] == '/') &
|
|
||||||
(isdigit(date[3]) != 0) &
|
|
||||||
(isdigit(date[4]) != 0) &
|
|
||||||
(date[5] == '/') &
|
|
||||||
(isdigit(date[6])!=0) & (isdigit(date[7])!=0) &
|
|
||||||
(isdigit(date[8])!=0) & (isdigit(date[9])!=0)
|
|
||||||
) {
|
|
||||||
strncpy(month, date, 2);
|
|
||||||
strncpy(day, date + 3, 2);
|
|
||||||
strncpy(year, date + 6, 4);
|
|
||||||
if ( (atoi(month) <= 12) &
|
|
||||||
(atoi(month) >= 1) &
|
|
||||||
(atoi(day) <= 31) &
|
|
||||||
(atoi(day) >= 1) &
|
|
||||||
(atoi(year) <= 9999) &
|
|
||||||
(atoi(year) > 1))
|
|
||||||
ok = 1;
|
|
||||||
}
|
|
||||||
return ok;
|
|
||||||
}
|
|
||||||
|
|
||||||
long
|
long
|
||||||
min2sec(unsigned minutes)
|
min2sec(unsigned minutes)
|
||||||
{
|
{
|
||||||
@ -923,3 +884,46 @@ erase_note(char **note, erase_flag_e flag)
|
|||||||
free(*note);
|
free(*note);
|
||||||
*note = NULL;
|
*note = NULL;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* Convert a string containing a date into three integers containing the year,
|
||||||
|
* month and day.
|
||||||
|
* Returns 1 if sucessfully converted or 0 if the string is an invalid date.
|
||||||
|
*/
|
||||||
|
int parse_date(char *date_string, int datefmt,
|
||||||
|
int *year, int *month, int *day) {
|
||||||
|
int in1, in2, in3;
|
||||||
|
int lyear, lmonth, lday;
|
||||||
|
if (date_string == NULL)
|
||||||
|
return 0;
|
||||||
|
if (sscanf(date_string, "%d / %d / %d", &in1, &in2, &in3) < 3 )
|
||||||
|
return 0;
|
||||||
|
switch (datefmt) {
|
||||||
|
case 1:
|
||||||
|
lmonth = in1;
|
||||||
|
lday = in2;
|
||||||
|
lyear = in3;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
lday = in1;
|
||||||
|
lmonth = in2;
|
||||||
|
lyear = in3;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
lyear = in1;
|
||||||
|
lmonth = in2;
|
||||||
|
lday = in3;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
if (lyear < 1 || lyear > 9999 || lmonth < 1 || lmonth > 12 ||
|
||||||
|
lday < 1 || lday > 31)
|
||||||
|
return 0;
|
||||||
|
if (year != NULL)
|
||||||
|
*year = lyear;
|
||||||
|
if (month != NULL)
|
||||||
|
*month = lmonth;
|
||||||
|
if (day != NULL)
|
||||||
|
*day = lday;
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: utils.h,v 1.27 2008/02/11 21:26:01 culot Exp $ */
|
/* $calcurse: utils.h,v 1.28 2008/04/09 20:38:29 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -82,12 +82,11 @@ int is_all_digit(char *);
|
|||||||
void status_bar(void);
|
void status_bar(void);
|
||||||
long date2sec(date_t, unsigned, unsigned);
|
long date2sec(date_t, unsigned, unsigned);
|
||||||
char *date_sec2hour_str(long);
|
char *date_sec2hour_str(long);
|
||||||
char *date_sec2date_str(long);
|
char *date_sec2date_str(long, char *);
|
||||||
void date_sec2ical_date(long, char *);
|
void date_sec2ical_date(long, char *);
|
||||||
void date_sec2ical_datetime(long, char *);
|
void date_sec2ical_datetime(long, char *);
|
||||||
long update_time_in_date(long, unsigned, unsigned);
|
long update_time_in_date(long, unsigned, unsigned);
|
||||||
long get_sec_date(date_t);
|
long get_sec_date(date_t);
|
||||||
int check_date(char *);
|
|
||||||
long min2sec(unsigned);
|
long min2sec(unsigned);
|
||||||
int check_time(char *);
|
int check_time(char *);
|
||||||
void draw_scrollbar(WINDOW *, int, int, int, int, int, bool);
|
void draw_scrollbar(WINDOW *, int, int, int, int, int, bool);
|
||||||
@ -101,5 +100,6 @@ long mystrtol(const char *);
|
|||||||
void print_option_incolor(WINDOW *, bool, int, int);
|
void print_option_incolor(WINDOW *, bool, int, int);
|
||||||
char *new_tempfile(const char *, int);
|
char *new_tempfile(const char *, int);
|
||||||
void erase_note(char **, erase_flag_e);
|
void erase_note(char **, erase_flag_e);
|
||||||
|
int parse_date(char *, int, int *, int *, int *);
|
||||||
|
|
||||||
#endif /* CALCURSE_UTILS_H */
|
#endif /* CALCURSE_UTILS_H */
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/* $calcurse: vars.c,v 1.6 2007/12/30 16:27:59 culot Exp $ */
|
/* $calcurse: vars.c,v 1.7 2008/04/09 20:38:29 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
* Copyright (c) 2004-2006 Frederic Culot
|
* Copyright (c) 2004-2008 Frederic Culot
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -25,6 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "i18n.h"
|
#include "i18n.h"
|
||||||
#include "calendar.h"
|
#include "calendar.h"
|
||||||
@ -101,6 +102,8 @@ vars_init(conf_t *conf)
|
|||||||
conf->auto_save = true;
|
conf->auto_save = true;
|
||||||
conf->skip_system_dialogs = false;
|
conf->skip_system_dialogs = false;
|
||||||
conf->skip_progress_bar = false;
|
conf->skip_progress_bar = false;
|
||||||
|
strncpy(conf->output_datefmt, "%D", 3);
|
||||||
|
conf->input_datefmt = 1;
|
||||||
|
|
||||||
/* Default external editor and pager */
|
/* Default external editor and pager */
|
||||||
ed = getenv("VISUAL");
|
ed = getenv("VISUAL");
|
||||||
|
12
src/vars.h
12
src/vars.h
@ -1,8 +1,8 @@
|
|||||||
/* $calcurse: vars.h,v 1.20 2008/02/13 19:44:37 culot Exp $ */
|
/* $calcurse: vars.h,v 1.21 2008/04/09 20:38:29 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
* Copyright (c) 2004-2007 Frederic Culot
|
* Copyright (c) 2004-2008 Frederic Culot
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -55,6 +55,12 @@
|
|||||||
#define STATUSHEIGHT 2
|
#define STATUSHEIGHT 2
|
||||||
#define NOTESIZ 6
|
#define NOTESIZ 6
|
||||||
|
|
||||||
|
#define DATEFMT(datefmt) (datefmt == 1 ? "%m/%d/%Y" : \
|
||||||
|
(datefmt == 2 ? "%d/%m/%Y" : "%Y/%m/%d"))
|
||||||
|
|
||||||
|
#define DATEFMT_DESC(datefmt) (datefmt == 1 ? _("mm/dd/yyyy") : \
|
||||||
|
(datefmt == 2 ? _("dd/mm/yyyy") : _("yyyy/mm/dd")))
|
||||||
|
|
||||||
struct pad_s {
|
struct pad_s {
|
||||||
int width;
|
int width;
|
||||||
int length;
|
int length;
|
||||||
@ -82,6 +88,8 @@ typedef struct {
|
|||||||
bool skip_progress_bar;
|
bool skip_progress_bar;
|
||||||
char *editor;
|
char *editor;
|
||||||
char *pager;
|
char *pager;
|
||||||
|
char output_datefmt[BUFSIZ]; /* format for displaying date */
|
||||||
|
int input_datefmt; /* format for reading date */
|
||||||
} conf_t;
|
} conf_t;
|
||||||
|
|
||||||
extern int col, row;
|
extern int col, row;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user