From cfb68d1c159fdd9f163ac562dbe561940981af7d Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Mon, 6 Mar 2023 14:26:11 -0700 Subject: [PATCH] #2482 Check if the string value is a datestring first. Then check if it's a number --- src/libcode/vx_data2d_nc_pinterp/var_info_nc_pinterp.cc | 8 +++++++- src/libcode/vx_data2d_nccf/var_info_nccf.cc | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/libcode/vx_data2d_nc_pinterp/var_info_nc_pinterp.cc b/src/libcode/vx_data2d_nc_pinterp/var_info_nc_pinterp.cc index 5795b7c12c..055e9ffca0 100644 --- a/src/libcode/vx_data2d_nc_pinterp/var_info_nc_pinterp.cc +++ b/src/libcode/vx_data2d_nc_pinterp/var_info_nc_pinterp.cc @@ -220,7 +220,13 @@ void VarInfoNcPinterp::set_magic(const ConcatString &nstr, const ConcatString &l else { int level = 0; double level_value = bad_data_double; - if (is_number(ptr2)) { + if (is_datestring(ptr2)) { + unixtime unix_time = timestring_to_unix(ptr2); + level = vx_data2d_dim_by_value; + level_value = unix_time; + as_offset = false; + } + else if (is_number(ptr2)) { if (as_offset) level = atoi(ptr2); else { level = vx_data2d_dim_by_value; diff --git a/src/libcode/vx_data2d_nccf/var_info_nccf.cc b/src/libcode/vx_data2d_nccf/var_info_nccf.cc index 75d4d6b082..184d38b7e1 100644 --- a/src/libcode/vx_data2d_nccf/var_info_nccf.cc +++ b/src/libcode/vx_data2d_nccf/var_info_nccf.cc @@ -281,7 +281,13 @@ void VarInfoNcCF::set_magic(const ConcatString &nstr, const ConcatString &lstr) // Single level int level = 0; double level_value = bad_data_double; - if (is_number(ptr2)) { + if (is_datestring(ptr2)) { + unixtime unix_time = timestring_to_unix(ptr2); + level = vx_data2d_dim_by_value; + level_value = unix_time; + as_offset = false; + } + else if (is_number(ptr2)) { if (as_offset) level = atoi(ptr2); else { level = vx_data2d_dim_by_value;