mirror of
https://gitea.psi.ch/ELOG/elog.git
synced 2026-09-08 17:13:56 +00:00
Fixed date import in CSV
SVN revision: 2163
This commit is contained in:
parent
8b4cd7fb71
commit
f8cece95f4
17
src/elogd.c
17
src/elogd.c
@ -14015,7 +14015,7 @@ void csv_import(LOGBOOK * lbs, const char *csv, const char *csvfile)
|
|||||||
const char *p;
|
const char *p;
|
||||||
char *line, *list;
|
char *line, *list;
|
||||||
char str[256], date[80], sep[80];
|
char str[256], date[80], sep[80];
|
||||||
int i, j, n, n_attr, iline, n_imported, textcol, attr_offset;
|
int i, j, n, n_attr, iline, n_imported, textcol, datecol, attr_offset;
|
||||||
BOOL first, in_quotes, filltext;
|
BOOL first, in_quotes, filltext;
|
||||||
time_t ltime;
|
time_t ltime;
|
||||||
|
|
||||||
@ -14027,6 +14027,7 @@ void csv_import(LOGBOOK * lbs, const char *csv, const char *csvfile)
|
|||||||
iline = n_imported = 0;
|
iline = n_imported = 0;
|
||||||
filltext = FALSE;
|
filltext = FALSE;
|
||||||
textcol = -1;
|
textcol = -1;
|
||||||
|
datecol = -1;
|
||||||
attr_offset = 0;
|
attr_offset = 0;
|
||||||
|
|
||||||
strcpy(sep, ",");
|
strcpy(sep, ",");
|
||||||
@ -14153,7 +14154,12 @@ void csv_import(LOGBOOK * lbs, const char *csv, const char *csvfile)
|
|||||||
/* derive attributes from first line */
|
/* derive attributes from first line */
|
||||||
if (first && isparam("head")) {
|
if (first && isparam("head")) {
|
||||||
|
|
||||||
/* skip message ID and date attributes */
|
/* check for date column */
|
||||||
|
for (i = attr_offset = 0; i < n; i++)
|
||||||
|
if (strieq(list + i * NAME_LENGTH, "Date"))
|
||||||
|
datecol = i;
|
||||||
|
|
||||||
|
/* skip message ID */
|
||||||
for (i = attr_offset = 0; i < n; i++)
|
for (i = attr_offset = 0; i < n; i++)
|
||||||
if (strieq(list + i * NAME_LENGTH, "Message ID") || strieq(list + i * NAME_LENGTH, "Date"))
|
if (strieq(list + i * NAME_LENGTH, "Message ID") || strieq(list + i * NAME_LENGTH, "Date"))
|
||||||
attr_offset++;
|
attr_offset++;
|
||||||
@ -14192,6 +14198,8 @@ void csv_import(LOGBOOK * lbs, const char *csv, const char *csvfile)
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
datecol = 1;
|
||||||
|
|
||||||
if (isparam("preview")) {
|
if (isparam("preview")) {
|
||||||
rsprintf("<tr>\n");
|
rsprintf("<tr>\n");
|
||||||
for (i = j = attr_offset; i < n_attr; i++) {
|
for (i = j = attr_offset; i < n_attr; i++) {
|
||||||
@ -14227,9 +14235,11 @@ void csv_import(LOGBOOK * lbs, const char *csv, const char *csvfile)
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
/* get date if present */
|
||||||
|
strlcpy(date, list + datecol*NAME_LENGTH, sizeof(date));
|
||||||
|
|
||||||
if (!filltext) {
|
if (!filltext) {
|
||||||
/* submit entry */
|
/* submit entry */
|
||||||
date[0] = 0;
|
|
||||||
if (el_submit
|
if (el_submit
|
||||||
(lbs, 0, FALSE, date, attr_list,
|
(lbs, 0, FALSE, date, attr_list,
|
||||||
(char (*)[NAME_LENGTH]) (list + attr_offset * NAME_LENGTH), n_attr, "", "", "", "plain",
|
(char (*)[NAME_LENGTH]) (list + attr_offset * NAME_LENGTH), n_attr, "", "", "", "plain",
|
||||||
@ -14243,7 +14253,6 @@ void csv_import(LOGBOOK * lbs, const char *csv, const char *csvfile)
|
|||||||
strlcpy(list + i * NAME_LENGTH, list + (i + 1) * NAME_LENGTH, NAME_LENGTH);
|
strlcpy(list + i * NAME_LENGTH, list + (i + 1) * NAME_LENGTH, NAME_LENGTH);
|
||||||
|
|
||||||
/* submit entry */
|
/* submit entry */
|
||||||
date[0] = 0;
|
|
||||||
if (el_submit
|
if (el_submit
|
||||||
(lbs, 0, FALSE, date, attr_list,
|
(lbs, 0, FALSE, date, attr_list,
|
||||||
(char (*)[NAME_LENGTH]) (list + attr_offset * NAME_LENGTH), n_attr, line, "", "", "plain",
|
(char (*)[NAME_LENGTH]) (list + attr_offset * NAME_LENGTH), n_attr, line, "", "", "plain",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user