mirror of https://github.com/ecmwf/eccodes.git
ECC-556: BUFR: 'typicalDate' calculation should cater for invalid year in BUFR4
This commit is contained in:
parent
e13fb5d228
commit
cac077117f
|
@ -28,8 +28,14 @@ unsigned[1] masterTablesVersionNumber : dump;
|
||||||
unsigned[1] localTablesVersionNumber : dump;
|
unsigned[1] localTablesVersionNumber : dump;
|
||||||
|
|
||||||
unsigned[2] typicalYear : dump;
|
unsigned[2] typicalYear : dump;
|
||||||
transient typicalYearOfCentury = typicalYear % 100;
|
transient typicalYear2 = typicalYear : hidden, no_copy;
|
||||||
transient typicalCentury = ( typicalYear - typicalYearOfCentury ) / 100 + 1 ;
|
if (typicalYear<100) {
|
||||||
|
# ECC-556: invalid year corrected. Assume 21st century!
|
||||||
|
transient typicalYear2 = (2000 + typicalYear) : hidden, no_copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
transient typicalYearOfCentury = typicalYear2 % 100;
|
||||||
|
transient typicalCentury = ( typicalYear2 - typicalYearOfCentury ) / 100 + 1 ;
|
||||||
|
|
||||||
unsigned[1] typicalMonth : dump;
|
unsigned[1] typicalMonth : dump;
|
||||||
unsigned[1] typicalDay : dump;
|
unsigned[1] typicalDay : dump;
|
||||||
|
@ -37,10 +43,10 @@ unsigned[1] typicalHour : dump;
|
||||||
unsigned[1] typicalMinute : dump;
|
unsigned[1] typicalMinute : dump;
|
||||||
unsigned[1] typicalSecond : dump;
|
unsigned[1] typicalSecond : dump;
|
||||||
|
|
||||||
meta ls.typicalDate sprintf("%.4d%.2d%.2d",typicalYear,typicalMonth,typicalDay) : dump,no_copy,read_only;
|
meta ls.typicalDate sprintf("%.4d%.2d%.2d",typicalYear2,typicalMonth,typicalDay) : dump,no_copy,read_only;
|
||||||
meta ls.typicalTime sprintf("%.2d%.2d%.2d",typicalHour,typicalMinute,typicalSecond) :dump,no_copy,read_only;
|
meta ls.typicalTime sprintf("%.2d%.2d%.2d",typicalHour,typicalMinute,typicalSecond) :dump,no_copy,read_only;
|
||||||
|
|
||||||
meta typicalDateTime julian_date(typicalYear,typicalMonth,typicalDay,typicalHour,typicalMinute,typicalSecond) ;
|
meta typicalDateTime julian_date(typicalYear2,typicalMonth,typicalDay,typicalHour,typicalMinute,typicalSecond) ;
|
||||||
|
|
||||||
alias ls.masterTablesVersionNumber=masterTablesVersionNumber;
|
alias ls.masterTablesVersionNumber=masterTablesVersionNumber;
|
||||||
alias ls.localTablesVersionNumber=localTablesVersionNumber;
|
alias ls.localTablesVersionNumber=localTablesVersionNumber;
|
||||||
|
|
|
@ -81,6 +81,7 @@ list( APPEND tests_data_reqd
|
||||||
ecc-393
|
ecc-393
|
||||||
ecc-433
|
ecc-433
|
||||||
ecc-490
|
ecc-490
|
||||||
|
ecc-556
|
||||||
gts_get
|
gts_get
|
||||||
gts_ls
|
gts_ls
|
||||||
gts_compare
|
gts_compare
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# Copyright 2005-2017 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.sh
|
||||||
|
set -u
|
||||||
|
|
||||||
|
# ---------------------------------------------------------
|
||||||
|
# This is the test for the JIRA issue ECC-556.
|
||||||
|
# It tests typicalDate for BUFR edition 4
|
||||||
|
# ---------------------------------------------------------
|
||||||
|
label="ecc-556-test"
|
||||||
|
|
||||||
|
# In this BUFR message the typicalYear should have been encoded
|
||||||
|
# as 2012 but it is actually 12!
|
||||||
|
input=${data_dir}/bufr/aaen_55.bufr
|
||||||
|
res=`${tools_dir}/bufr_get -p edition,typicalYear,typicalDate $input`
|
||||||
|
[ "$res" = "4 12 20121102" ]
|
||||||
|
|
||||||
|
# Now try a BUFR4 file with correctly coded year
|
||||||
|
input=${data_dir}/bufr/PraticaTemp.bufr
|
||||||
|
res=`${tools_dir}/bufr_get -p edition,typicalYear,typicalDate $input`
|
||||||
|
[ "$res" = "4 2015 20151202" ]
|
Loading…
Reference in New Issue