mirror of
https://github.com/mdbtools/mdbtools.git
synced 2025-04-05 14:50:20 +08:00
Merge 196bcbfbff
into 6640f9c707
This commit is contained in:
commit
4c040a7239
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
@ -49,7 +49,7 @@ jobs:
|
||||
glib: [ enable-glib, disable-glib ]
|
||||
steps:
|
||||
- name: Install packages
|
||||
run: brew install bison gawk automake
|
||||
run: brew install bison gawk automake glib
|
||||
- uses: actions/checkout@v2
|
||||
- name: Fetch test data
|
||||
run: git clone https://github.com/mdbtools/mdbtestdata.git test
|
||||
@ -89,7 +89,7 @@ jobs:
|
||||
- name: Remove packages
|
||||
run: brew unlink unixodbc
|
||||
- name: Install packages
|
||||
run: brew install libiodbc bison gawk automake
|
||||
run: brew install libiodbc bison gawk automake glib
|
||||
- uses: actions/checkout@v2
|
||||
- name: Fetch test data
|
||||
run: git clone https://github.com/mdbtools/mdbtestdata.git test
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -14,6 +14,7 @@ m4/
|
||||
!m4/ccalias.m4
|
||||
!m4/iconv.m4
|
||||
!m4/readline.m4
|
||||
/test/
|
||||
config.log
|
||||
config.status
|
||||
configure
|
||||
|
@ -894,9 +894,6 @@ mdb_date_to_tm(double td, struct tm *t)
|
||||
long yr, q;
|
||||
const int *cal;
|
||||
|
||||
if (td < 0.0 || td > 1e6) // About 2700 AD
|
||||
return;
|
||||
|
||||
yr = 1;
|
||||
day = (long)(td);
|
||||
time = (long)((td - day) * 86400.0 + 0.5);
|
||||
@ -940,12 +937,21 @@ static char *
|
||||
mdb_date_to_string(MdbHandle *mdb, const char *fmt, void *buf, int start)
|
||||
{
|
||||
struct tm t = { 0 };
|
||||
char *text = g_malloc(mdb->bind_size);
|
||||
char *text = NULL;
|
||||
double td = mdb_get_double(buf, start);
|
||||
|
||||
mdb_date_to_tm(td, &t);
|
||||
|
||||
strftime(text, mdb->bind_size, mdb->date_fmt, &t);
|
||||
// limit dates to protect from overflow.
|
||||
// 1e6 days is ~2700 years, centered at 1900, so this range is:
|
||||
// Sunday, February 4, 839 BC to Tuesday, November 28, 4637
|
||||
if (td < -1e6 || td > 1e6) {
|
||||
// an "invalid date" would perhaps be better than null (TODO)
|
||||
// fprintf(stderr, "Warning: mdb_date_to_string called on unsupported date with %f days.\n", td);
|
||||
text = g_strdup("");
|
||||
} else {
|
||||
text = g_malloc(mdb->bind_size);
|
||||
mdb_date_to_tm(td, &t);
|
||||
strftime(text, mdb->bind_size, fmt, &t);
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
@ -1046,9 +1052,6 @@ char *mdb_col_to_string(MdbHandle *mdb, void *buf, int start, int datatype, int
|
||||
size, text, mdb->bind_size);
|
||||
}
|
||||
break;
|
||||
case MDB_DATETIME:
|
||||
text = mdb_date_to_string(mdb, mdb->date_fmt, buf, start);
|
||||
break;
|
||||
case MDB_MEMO:
|
||||
text = mdb_memo_to_string(mdb, start, size);
|
||||
break;
|
||||
|
@ -16,3 +16,4 @@
|
||||
./src/util/mdb-ver test/data/ASampleDatabase.accdb
|
||||
./src/util/mdb-ver test/data/nwind.mdb
|
||||
./src/util/mdb-queries test/data/ASampleDatabase.accdb qryCostsSummedByOwner
|
||||
./src/util/mdb-export -X '@' -d '|' -D %F -T '%F %T' -R "\n" -q '"' -H -e test/data/DateTestDatabase.mdb DateTest
|
Loading…
Reference in New Issue
Block a user