Skip to content

Commit

Permalink
Set to NaN if input datetime strings are not in ISO datetime format (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
seisman authored Jun 1, 2020
1 parent 3003c50 commit 362acc1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/gmt_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -3397,7 +3397,7 @@ GMT_LOCAL int gmtapi_write_matrix (struct GMT_CTRL *GMT, void *dest, unsigned in
GMT_2D_to_index = gmtapi_get_2d_to_index (GMT->parent, M->shape, GMT_GRID_IS_REAL);
if ((api_get_val = gmtapi_select_get_function (GMT->parent, M->type)) == NULL)
return (GMT_NOT_A_VALID_TYPE);


/* Start writing Matrix to fp */

Expand Down Expand Up @@ -12767,10 +12767,13 @@ int GMT_Put_Vector (void *V_API, struct GMT_VECTOR *V, unsigned int col, unsigne
return GMT_MEMORY_ERROR;
}
for (row = 0; row < V->n_rows; row++) {
if (gmt_scanf (API->GMT, dt[row], GMT_IS_ABSTIME, &(t_vector[row])) == GMT_IS_NAN) n_bad++;
if (gmt_scanf (API->GMT, dt[row], GMT_IS_ABSTIME, &(t_vector[row])) == GMT_IS_NAN) {
n_bad++;
t_vector[row] = API->GMT->session.d_NaN;
}
}
V->type[col] = GMT_DOUBLE; V->data[col].f8 = t_vector;
if (n_bad) GMT_Report (API, GMT_MSG_ERROR, "Unable to parse %" PRIu64 " datetime strings (ISO datetime format required)\n", n_bad);
if (n_bad) GMT_Report (API, GMT_MSG_WARNING, "Unable to parse %" PRIu64 " datetime strings (ISO datetime format required)\n", n_bad);
break;
default:
return_error (API, GMT_NOT_A_VALID_TYPE);
Expand Down

0 comments on commit 362acc1

Please sign in to comment.