mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 22:03:23 +00:00
Parse date and time from on APD import
This will parse the date and time information on CSV import if the file name matches the one used by APD log viewer (date and time are available in the file name). Hard coding the year to 20?? is a bit unfortunate, but as there is only 2 digits in the year, we have to invent something. And it would be quite optimistic to assume this will bite us back any time soon :D Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
029b524f37
commit
1902d527d5
2 changed files with 18 additions and 3 deletions
|
@ -974,7 +974,7 @@ int parse_csv_file(const char *filename, char **params, int pnr, const char *csv
|
|||
return -1;
|
||||
}
|
||||
mem.size = ptr - (char*)mem.buffer;
|
||||
} else {
|
||||
} else if (strcmp(params[0], "date")) {
|
||||
time(&now);
|
||||
timep = localtime(&now);
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <QShortcut>
|
||||
#include <QDrag>
|
||||
#include <QMimeData>
|
||||
#include <QRegExp>
|
||||
|
||||
static QString subsurface_mimedata = "subsurface/csvcolumns";
|
||||
static QString subsurface_index = "subsurface/csvindex";
|
||||
|
@ -827,9 +828,16 @@ void DiveLogImportDialog::on_buttonBox_accepted()
|
|||
sample->tts.seconds *= 60;
|
||||
}
|
||||
} else {
|
||||
char *params[47];
|
||||
char *params[49];
|
||||
int pnr = 0;
|
||||
|
||||
QRegExp apdRe("^.*[/\\][0-9a-zA-Z]*_([0-9]{6})_([0-9]{6})\\.apd");
|
||||
if (apdRe.exactMatch(fileNames[i])) {
|
||||
params[pnr++] = strdup("date");
|
||||
params[pnr++] = strdup("20" + apdRe.cap(1).toLatin1());
|
||||
params[pnr++] = strdup("time");
|
||||
params[pnr++] = strdup("1" + apdRe.cap(2).toLatin1());
|
||||
}
|
||||
pnr = setup_csv_params(r, params, pnr);
|
||||
parse_csv_file(fileNames[i].toUtf8().data(), params, pnr - 1,
|
||||
specialCSV.contains(ui->knownImports->currentIndex()) ? CSVApps[ui->knownImports->currentIndex()].name.toUtf8().data() : "csv");
|
||||
|
@ -894,9 +902,16 @@ void DiveLogImportDialog::on_buttonBox_accepted()
|
|||
|
||||
parse_manual_file(fileNames[i].toUtf8().data(), params, pnr - 1);
|
||||
} else {
|
||||
char *params[47];
|
||||
char *params[49];
|
||||
int pnr = 0;
|
||||
|
||||
QRegExp apdRe("^.*[/\\][0-9a-zA-Z]*_([0-9]{6})_([0-9]{6})\\.apd");
|
||||
if (apdRe.exactMatch(fileNames[i])) {
|
||||
params[pnr++] = strdup("date");
|
||||
params[pnr++] = strdup("20" + apdRe.cap(1).toLatin1());
|
||||
params[pnr++] = strdup("time");
|
||||
params[pnr++] = strdup("1" + apdRe.cap(2).toLatin1());
|
||||
}
|
||||
pnr = setup_csv_params(r, params, pnr);
|
||||
parse_csv_file(fileNames[i].toUtf8().data(), params, pnr - 1,
|
||||
specialCSV.contains(ui->knownImports->currentIndex()) ? CSVApps[ui->knownImports->currentIndex()].name.toUtf8().data() : "csv");
|
||||
|
|
Loading…
Add table
Reference in a new issue