From 16e0e3c5133096cd2bb53beb3b39540089ceafa7 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Mon, 6 Mar 2023 14:23:48 -0700 Subject: [PATCH] #2482 Check if the string value is a datestring first. Then check if it's a number --- .../vx_data2d_nc_pinterp/var_info_nc_pinterp.cc | 14 +++++++------- src/libcode/vx_data2d_nccf/var_info_nccf.cc | 14 +++++++------- 2 files changed, 14 insertions(+), 14 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 f7e51f84cf..76cbfe681c 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,19 +220,19 @@ 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; level_value = atof(ptr2); } } - else 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 { mlog << Error << "\n" << method_name << "trouble parsing NetCDF dimension value \"" diff --git a/src/libcode/vx_data2d_nccf/var_info_nccf.cc b/src/libcode/vx_data2d_nccf/var_info_nccf.cc index ee3880971c..dca1f9b47d 100644 --- a/src/libcode/vx_data2d_nccf/var_info_nccf.cc +++ b/src/libcode/vx_data2d_nccf/var_info_nccf.cc @@ -281,19 +281,19 @@ 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; level_value = atof(ptr2); } } - else 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 { mlog << Error << "\n" << method_name << "trouble parsing NetCDF dimension value \""