diff --git a/definitions/bufr/section.1.3.def b/definitions/bufr/section.1.3.def index 84ac947b0..811b0955a 100644 --- a/definitions/bufr/section.1.3.def +++ b/definitions/bufr/section.1.3.def @@ -20,7 +20,8 @@ unsigned[1] localTablesVersionNumber : dump; transient typicalCentury=21; unsigned[1] typicalYearOfCentury : dump; -transient typicalYear = (typicalCentury - 1) * 100 + typicalYearOfCentury : no_copy; +# ECC-1840: Use the 'evaluate' accessor so typicalYear is updated if user changes typicalCentury +meta typicalYear evaluate( (typicalCentury - 1) * 100 + typicalYearOfCentury ) : no_copy; unsigned[1] typicalMonth : dump; unsigned[1] typicalDay : dump; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 71116ab24..0169e4986 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -156,6 +156,7 @@ if( HAVE_BUILD_TOOLS ) bufr_ecc-1304 bufr_ecc-1347 bufr_ecc-1395 + bufr_ecc-1840 bufr_json_samples bufr_ecc-359 bufr_ecc-517 diff --git a/tests/bufr_ecc-1840.sh b/tests/bufr_ecc-1840.sh new file mode 100755 index 000000000..34acb5bf6 --- /dev/null +++ b/tests/bufr_ecc-1840.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# (C) Copyright 2005- ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# +# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by +# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. +# + +. ./include.ctest.sh + +REDIRECT=/dev/null + +label="bufr_ecc-1840_test" +tempBufr=temp.$label.bufr +tempFilt=temp.$label.filt +tempLog=temp.$label.log +tempOut=temp.$label.txt +tempRef=temp.$label.ref + +sample_bufr3=$ECCODES_SAMPLES_PATH/BUFR3.tmpl + +# This sample has: +# typicalYearOfCentury = 12 +# typicalMonth = 10 +# typicalDay = 31 +result=$(${tools_dir}/bufr_get -p typicalYear,typicalDate $sample_bufr3) +[ "$result" = "2012 20121031" ] +result=$(${tools_dir}/bufr_get -p typicalYear,typicalDate -s typicalCentury=20 $sample_bufr3) +[ "$result" = "1912 19121031" ] + + +# Clean up +rm -f $tempBufr $tempFilt $tempLog $tempOut $tempRef