Commit 8a591cf8 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

taxis: add support for years less than zero

parent fb7bb4c1
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
* replace calendar module by a new one because of date/time problems * replace calendar module by a new one because of date/time problems
with years < 0 [report: Veronika Gayler] with years < 0 [report: Veronika Gayler]
* add module timebase * add module timebase
* taxis: add support for years less than zero
* use always decode_date and encode_date to decode/encode date * use always decode_date and encode_date to decode/encode date
* Version 1.0.8 released * Version 1.0.8 released
......
/* Generated automatically from m214003 on Thu Jul 19 14:54:00 CEST 2007 */ /* Generated automatically from m214003 on Tue Jul 31 09:15:55 CEST 2007 */
/* GRIBLIB_VERSION="1.0.6" */
#if defined (HAVE_CONFIG_H) #if defined (HAVE_CONFIG_H)
# include "config.h" # include "config.h"
...@@ -919,7 +921,12 @@ int gribRefDate(int *isec1) ...@@ -919,7 +921,12 @@ int gribRefDate(int *isec1)
ryear = ISEC1_Year; ryear = ISEC1_Year;
if ( ryear != 255 ) if ( ryear != 255 )
ryear = ((ISEC1_Century-1)*100 + ISEC1_Year); {
if ( ISEC1_Century > 127 )
ryear = ((ISEC1_Century-1-256)*100 + ISEC1_Year);
else
ryear = ((ISEC1_Century-1)*100 + ISEC1_Year);
}
else else
ryear = 1; ryear = 1;
...@@ -977,7 +984,12 @@ void gribDateTime(int *isec1, int *date, int *time) ...@@ -977,7 +984,12 @@ void gribDateTime(int *isec1, int *date, int *time)
if ( ISEC1_Century ) if ( ISEC1_Century )
{ {
if ( ryear != 255 ) if ( ryear != 255 )
ryear = ((ISEC1_Century-1)*100 + ISEC1_Year); {
if ( ISEC1_Century > 127 )
ryear = ((ISEC1_Century-1-256)*100 + ISEC1_Year);
else
ryear = ((ISEC1_Century-1)*100 + ISEC1_Year);
}
else else
ryear = 1; ryear = 1;
} }
...@@ -8037,7 +8049,7 @@ int gribUnzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbu ...@@ -8037,7 +8049,7 @@ int gribUnzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbu
return (gribLen); return (gribLen);
} }
static const char grb_libvers[] = "1.0.6" " of ""Jul 19 2007"" ""14:54:00"; static const char grb_libvers[] = "1.0.6" " of ""Jul 31 2007"" ""09:15:56";
......
...@@ -15,10 +15,16 @@ rm -f ${PROG} ...@@ -15,10 +15,16 @@ rm -f ${PROG}
DATE=`date` DATE=`date`
if test -f config.h ; then
CDILIBVERSION=`grep PACKAGE_VERSION config.h | cut -f3 -d" "`
fi
cat > ${PROG} << EOR cat > ${PROG} << EOR
/* Generated automatically from $USER on $DATE */ /* Generated automatically from $USER on $DATE */
/* CDILIB_VERSION=$CDILIBVERSION */
#if defined (HAVE_CONFIG_H) #if defined (HAVE_CONFIG_H)
# include "config.h" # include "config.h"
#endif #endif
...@@ -99,6 +105,7 @@ cat $c | grep -v '#include' >> ${PROG} ...@@ -99,6 +105,7 @@ cat $c | grep -v '#include' >> ${PROG}
if test -f config.h ; then if test -f config.h ; then
cpp -P -DHAVE_CONFIG_H version.c >> ${PROG} cpp -P -DHAVE_CONFIG_H version.c >> ${PROG}
CDIVERSION=`grep PACKAGE_VERSION config.h | cut -f3 -d" "`
else else
echo "error: missing config.h" echo "error: missing config.h"
fi fi
......
...@@ -999,8 +999,11 @@ void splitTimevalue(double timevalue, int timeunit, int *date, int *time) ...@@ -999,8 +999,11 @@ void splitTimevalue(double timevalue, int timeunit, int *date, int *time)
{ {
timevalue /= 24; timevalue /= 24;
vdate = (int) timevalue; vdate = (int) timevalue;
vtime = (int) ((timevalue - vdate)*1440 + 0.01); if ( vdate < 0 )
vtime = (int) (-(timevalue - vdate)*1440 + 0.01);
else
vtime = (int) ((timevalue - vdate)*1440 + 0.01);
hour = vtime / 60; hour = vtime / 60;
minute = vtime - hour*60; minute = vtime - hour*60;
vtime = hour*100 + minute; vtime = hour*100 + minute;
...@@ -1008,7 +1011,10 @@ void splitTimevalue(double timevalue, int timeunit, int *date, int *time) ...@@ -1008,7 +1011,10 @@ void splitTimevalue(double timevalue, int timeunit, int *date, int *time)
else if ( timeunit == TUNIT_DAY ) else if ( timeunit == TUNIT_DAY )
{ {
vdate = (int) timevalue; vdate = (int) timevalue;
vtime = (int) ((timevalue - vdate)*1440 + 0.01); if ( vdate < 0 )
vtime = (int) (-(timevalue - vdate)*1440 + 0.01);
else
vtime = (int) ((timevalue - vdate)*1440 + 0.01);
hour = vtime / 60; hour = vtime / 60;
minute = vtime - hour*60; minute = vtime - hour*60;
...@@ -1052,7 +1058,10 @@ double encode_timeval(int date, int time, TAXIS *taxis) ...@@ -1052,7 +1058,10 @@ double encode_timeval(int date, int time, TAXIS *taxis)
{ {
int hour = time / 100; int hour = time / 100;
int minute = time - hour*100; int minute = time - hour*100;
timevalue = date + (hour*60 + minute)/1440.; if ( date < 0 )
timevalue = -(-date + (hour*60 + minute)/1440.);
else
timevalue = date + (hour*60 + minute)/1440.;
} }
} }
else else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment