diff --git a/src/accessor/grib_accessor_class_julian_date.cc b/src/accessor/grib_accessor_class_julian_date.cc index fa42ed970..fc535c408 100644 --- a/src/accessor/grib_accessor_class_julian_date.cc +++ b/src/accessor/grib_accessor_class_julian_date.cc @@ -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; diff --git a/tests/bufr_filter_misc.sh b/tests/bufr_filter_misc.sh index accdae9b3..710c8e070 100755 --- a/tests/bufr_filter_misc.sh +++ b/tests/bufr_filter_misc.sh @@ -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 diff --git a/tests/grib_step.sh b/tests/grib_step.sh index 274f1f7ab..4a098fd58 100755 --- a/tests/grib_step.sh +++ b/tests/grib_step.sh @@ -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 # -------------------------------------