diff --git a/main/gbx/gbx_date.c b/main/gbx/gbx_date.c index 41ffcae06..23645f603 100644 --- a/main/gbx/gbx_date.c +++ b/main/gbx/gbx_date.c @@ -146,8 +146,6 @@ DATE_SERIAL *DATE_split(VALUE *value) nday = value->_date.date; nmsec = value->_date.time; - //fprintf(stderr, "DATE_split: (%d %d)\n", nday, nmsec); - if (nday > 0) nmsec += date_timezone * 1000; diff --git a/main/gbx/gbx_local.c b/main/gbx/gbx_local.c index 4deb79aef..af930b701 100644 --- a/main/gbx/gbx_local.c +++ b/main/gbx/gbx_local.c @@ -1207,19 +1207,20 @@ static void add_date_token(DATE_SERIAL *date, char *token, int count) } -bool LOCAL_format_date(DATE_SERIAL *date, int fmt_type, const char *fmt, int len_fmt, char **str, int *len_str) +bool LOCAL_format_date(const DATE_SERIAL *date, int fmt_type, const char *fmt, int len_fmt, char **str, int *len_str) { + DATE_SERIAL vdate; char c; bool esc; int pos; int pos_ampm = -1; struct tm date_tm; - char real_hour = 0; char token; int token_count; local_current = &LOCAL_local; + vdate = *date; switch(fmt_type) { @@ -1283,11 +1284,10 @@ bool LOCAL_format_date(DATE_SERIAL *date, int fmt_type, const char *fmt, int len if (strncasecmp(&fmt[pos], "am/pm", 5) == 0) { pos_ampm = pos; - real_hour = date->hour; - if (date->hour >= 12) - date->hour -= 12; - if (date->hour == 0) - date->hour = 12; + if (vdate.hour > 12) + vdate.hour -= 12; + else if (vdate.hour == 0) + vdate.hour = 12; break; } } @@ -1318,7 +1318,7 @@ bool LOCAL_format_date(DATE_SERIAL *date, int fmt_type, const char *fmt, int len date_tm.tm_sec = date->sec; date_tm.tm_min = date->min; - date_tm.tm_hour = real_hour; + date_tm.tm_hour = date->hour; date_tm.tm_mday = 1; date_tm.tm_mon = 0; date_tm.tm_year = 0; @@ -1333,7 +1333,7 @@ bool LOCAL_format_date(DATE_SERIAL *date, int fmt_type, const char *fmt, int len { if (c != token) { - add_date_token(date, &token, token_count); + add_date_token(&vdate, &token, token_count); if (token == 'h' && c == 'm') c = 'n'; @@ -1345,7 +1345,7 @@ bool LOCAL_format_date(DATE_SERIAL *date, int fmt_type, const char *fmt, int len } else { - add_date_token(date, &token, token_count); + add_date_token(&vdate, &token, token_count); if (esc) put_char(c); else if (c == '/') @@ -1357,7 +1357,7 @@ bool LOCAL_format_date(DATE_SERIAL *date, int fmt_type, const char *fmt, int len } } - add_date_token(date, &token, token_count); + add_date_token(&vdate, &token, token_count); /* on retourne le r�ultat */ diff --git a/main/gbx/gbx_local.h b/main/gbx/gbx_local.h index 610abc755..c4633098d 100755 --- a/main/gbx/gbx_local.h +++ b/main/gbx/gbx_local.h @@ -108,7 +108,7 @@ EXTERN char LOCAL_first_day_of_week; void LOCAL_init(void); void LOCAL_exit(void); bool LOCAL_format_number(double number, int fmt_type, const char *fmt, int len_fmt, char **str, int *len_str, bool local); -bool LOCAL_format_date(DATE_SERIAL *date, int fmt_type, const char *fmt, int len_fmt, char **str, int *len_str); +bool LOCAL_format_date(const DATE_SERIAL *date, int fmt_type, const char *fmt, int len_fmt, char **str, int *len_str); const char *LOCAL_get_lang(void); void LOCAL_set_lang(const char *lang); const char *LOCAL_gettext(const char *msgid);