@@ -460,7 +460,7 @@ parse_iso_8601_datetime(char *str, int len,
460
460
}
461
461
462
462
/* Check the casting rule */
463
- if (unit != -1 && !can_cast_datetime64_units (bestunit , unit ,
463
+ if (!can_cast_datetime64_units (bestunit , unit ,
464
464
casting )) {
465
465
PyErr_Format (PyExc_TypeError , "Cannot parse \"%s\" as unit "
466
466
"'%s' using casting rule %s" ,
@@ -503,7 +503,7 @@ parse_iso_8601_datetime(char *str, int len,
503
503
}
504
504
505
505
/* Check the casting rule */
506
- if (unit != -1 && !can_cast_datetime64_units (bestunit , unit ,
506
+ if (!can_cast_datetime64_units (bestunit , unit ,
507
507
casting )) {
508
508
PyErr_Format (PyExc_TypeError , "Cannot parse \"%s\" as unit "
509
509
"'%s' using casting rule %s" ,
@@ -975,7 +975,7 @@ parse_iso_8601_datetime(char *str, int len,
975
975
}
976
976
977
977
/* Check the casting rule */
978
- if (unit != -1 && !can_cast_datetime64_units (bestunit , unit ,
978
+ if (!can_cast_datetime64_units (bestunit , unit ,
979
979
casting )) {
980
980
PyErr_Format (PyExc_TypeError , "Cannot parse \"%s\" as unit "
981
981
"'%s' using casting rule %s" ,
@@ -1005,11 +1005,6 @@ get_datetime_iso_8601_strlen(int local, PANDAS_DATETIMEUNIT base)
1005
1005
{
1006
1006
int len = 0 ;
1007
1007
1008
- /* If no unit is provided, return the maximum length */
1009
- if (base == -1 ) {
1010
- return PANDAS_DATETIME_MAX_ISO8601_STRLEN ;
1011
- }
1012
-
1013
1008
switch (base ) {
1014
1009
/* Generic units can only be used to represent NaT */
1015
1010
/*case PANDAS_FR_GENERIC:*/
@@ -1146,28 +1141,13 @@ make_iso_8601_datetime(pandas_datetimestruct *dts, char *outstr, int outlen,
1146
1141
local = 0 ;
1147
1142
}
1148
1143
1149
- /* Automatically detect a good unit */
1150
- if (base == -1 ) {
1151
- base = lossless_unit_from_datetimestruct (dts );
1152
- /*
1153
- * If there's a timezone, use at least minutes precision,
1154
- * and never split up hours and minutes by default
1155
- */
1156
- if ((base < PANDAS_FR_m && local ) || base == PANDAS_FR_h ) {
1157
- base = PANDAS_FR_m ;
1158
- }
1159
- /* Don't split up dates by default */
1160
- else if (base < PANDAS_FR_D ) {
1161
- base = PANDAS_FR_D ;
1162
- }
1163
- }
1164
1144
/*
1165
1145
* Print weeks with the same precision as days.
1166
1146
*
1167
1147
* TODO: Could print weeks with YYYY-Www format if the week
1168
1148
* epoch is a Monday.
1169
1149
*/
1170
- else if (base == PANDAS_FR_W ) {
1150
+ if (base == PANDAS_FR_W ) {
1171
1151
base = PANDAS_FR_D ;
1172
1152
}
1173
1153
0 commit comments