ECC-1999: GRIB: Decoding validityDateTime as a string gives incorrect value

This commit is contained in:
shahramn 2024-12-25 12:44:30 +00:00
parent 7718de2dee
commit 10f710c569
3 changed files with 12 additions and 3 deletions

View File

@ -16,9 +16,11 @@ grib_accessor* grib_accessor_julian_date = &_grib_accessor_julian_date;
void grib_accessor_julian_date_t::init(const long l, grib_arguments* c)
{
grib_accessor_double_t::init(l, c);
int n = 0;
grib_handle* h = grib_handle_of_accessor(this);
const int arg_count = c->get_count();
ECCODES_ASSERT( arg_count == 2 || arg_count == 6);
int n = 0;
year_ = c->get_name(h, n++);
month_ = c->get_name(h, n++);
@ -200,6 +202,13 @@ int grib_accessor_julian_date_t::unpack_string(char* val, size_t* len)
ret = grib_get_long(h, hms_, &hms);
if (ret != GRIB_SUCCESS)
return ret;
// ECC-1999: If hms_ is passed in in 'hhmm' format
// its largest value would be 2459
if (hms < 2500) {
hms *= 100; // convert to seconds e.g., 1205 -> 120500
}
hour = hms / 10000;
hms %= 10000;
minute = hms / 100;

View File

@ -1239,7 +1239,7 @@ match
rdbtimeDate=20121030 rdbtimeTime=001019 rdbDateTime=2456230.507164 mystart=2456230.708333 myend=2456230.708333
rdbDateTime=20121030 001019
myEndDate=2017-05-22 12:15:23 myEndDateTime=2457896.01068 myEndDate=20170522 myEndTime=121523
myEndDate=2012-10-30 00:10:19 myEndDateTime=2456230.50716 myEndDate=20121030 myEndTime=1019
myEndDate=2012-10-30 10:19:00 myEndDateTime=2456230.50716 myEndDate=20121030 myEndTime=1019
userDateTimeStart=2457896.88347 userDateStart=20170523 userTimeStart=91212 2017/05/23 09-12:12
userDateTimeStart=2457896.88347 userDateStart=20170523 userTimeStart=91212 20170523 091212
userDateTimeStart=2457896.88347 userDateStart=20170523 userTimeStart=91212 20170523091212

View File

@ -153,7 +153,7 @@ grib_check_key_equals $temp "stepRange,startStep,endStep" "14 14 14"
input=${data_dir}/constant_field.grib2
grib_check_key_equals $input "dataDate,dataTime,step" "20061205 1200 6"
grib_check_key_equals $input "validityDate,validityTime" "20061205 1800"
grib_check_key_equals $input "validityDateTime:s" "20061205 001800"
grib_check_key_equals $input "validityDateTime:s" "20061205 180000"
# ECC-1704: Key validityTime as string
# -------------------------------------