Skip to content

Commit 80c46a0

Browse files
Revert "reset dec='\0' to detect numbers while dec is undecided"
This reverts commit 7ecf3d4.
1 parent 7ecf3d4 commit 80c46a0

File tree

3 files changed

+6
-13
lines changed

3 files changed

+6
-13
lines changed

NEWS.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66

77
1. In `DT[, variable := value]`, when value is class `POSIXlt`, we automatically coerce it to class `POSIXct` instead, [#1724](https://github.com/Rdatatable/data.table/issues/1724). Thanks to @linzhp for the report, and Benjamin Schwendinger for the fix.
88

9-
## BUG FIXES
10-
11-
1. `fread()` automatically detects timestamps with microseconds again, [#6440](https://github.com/Rdatatable/data.table/issues/6440). This was a regression due to interference with new `dec='auto'` support. Thanks @kav2k for the concise report and @MichaelChirico for the fix.
12-
139
## NOTES
1410

1511
1. Tests run again when some Suggests packages are missing, [#6411](https://github.com/Rdatatable/data.table/issues/6411). Thanks @aadler for the note and @MichaelChirico for the fix.

src/fread.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,7 @@ static void parse_iso8601_timestamp(FieldParseContext *ctx)
10381038
if (second == NA_FLOAT64 || second < 0 || second >= 60)
10391039
goto fail;
10401040

1041-
if (*ch == 'Z') {
1041+
if (*ch == 'Z') {
10421042
ch++; // "Zulu time"=UTC
10431043
} else {
10441044
if (*ch == ' ')
@@ -1075,6 +1075,7 @@ static void parse_iso8601_timestamp(FieldParseContext *ctx)
10751075

10761076
date_only:
10771077

1078+
//Rprintf("date=%d\thour=%d\tz_hour=%d\tminute=%d\ttz_minute=%d\tsecond=%.1f\n", date, hour, tz_hour, minute, tz_minute, second);
10781079
// cast upfront needed to prevent silent overflow
10791080
*target = 86400*(double)date + 3600*(hour - tz_hour) + 60*(minute - tz_minute) + second;
10801081

@@ -1235,13 +1236,9 @@ static int detect_types( const char **pch, int8_t type[], int ncol, bool *bumped
12351236
}
12361237
}
12371238
ch = fieldStart;
1238-
if (autoDec && IS_DEC_TYPE(tmpType[field])) {
1239-
if (dec == '.') { // '.' didn't parse a double; try ','
1240-
dec = ',';
1241-
continue; // i.e., restart since tmpType not incremented
1242-
} else if (dec == ',') { // ',' didn't parse a double either; reset
1243-
dec = '\0';
1244-
}
1239+
if (autoDec && IS_DEC_TYPE(tmpType[field]) && dec == '.') { // . didn't parse a double; try ,
1240+
dec = ',';
1241+
continue;
12451242
}
12461243
while (++tmpType[field]<CT_STRING && disabled_parsers[tmpType[field]]) {};
12471244
*bumped = true;

src/fread.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ typedef enum {
3636
NUMTYPE // placeholder for the number of types including drop; used for allocation and loop bounds
3737
} colType;
3838

39-
#define IS_DEC_TYPE(x) ((x) == CT_FLOAT64 || (x) == CT_FLOAT64_EXT || (x) == CT_ISO8601_TIME) // types where dec matters
39+
#define IS_DEC_TYPE(x) ((x) == CT_FLOAT64 || (x) == CT_FLOAT64_EXT) // types where dec matters
4040

4141
extern int8_t typeSize[NUMTYPE];
4242
extern const char typeName[NUMTYPE][10];

0 commit comments

Comments
 (0)