Commit fa1c08fb authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

added support for timeunit 's'

parent 489e48d8
......@@ -8,7 +8,7 @@
#define MIN_TAXES 1024 /* minimum number of taxes */
#define MAX_TAXES 65536 /* maximum number of taxes */
#define MAX_ZAXES 1024 /* maximum number of zaxes */
#define MAX_GRIDS 1024 /* maximum number of grids */
#define MAX_GRIDS 8192 /* maximum number of grids */
#define MAX_INSTS 1024 /* maximum number of instituts */
#define MAX_MODELS 1024 /* maximum number of models */
#define MAX_GRIDS_PS 128 /* maximum number of different grids per stream */
......
......@@ -125,6 +125,10 @@ int get_timeunit(int len, char *ptu)
else if ( memcmp(ptu, "calendar_month", 14) == 0 ) timeunit = TUNIT_MONTH;
else if ( memcmp(ptu, "year", 4) == 0 ) timeunit = TUNIT_YEAR;
}
else if ( len == 1 )
{
if ( ptu[0] == 's' ) timeunit = TUNIT_SECOND;
}
return (timeunit);
}
......
......@@ -1214,6 +1214,28 @@ double vtime2timeval(int vdate, int vtime, taxis_t *taxis)
}
void conv_timeval(double timevalue, int *rvdate, int *rvtime)
{
int vdate = 0, vtime = 0;
int hour, minute, second;
int daysec;
vdate = (int) timevalue;
if ( vdate < 0 )
daysec = (int) (-(timevalue - vdate)*86400 + 0.01);
else
daysec = (int) ( (timevalue - vdate)*86400 + 0.01);
hour = daysec / 3600;
minute = (daysec - hour*3600)/60;
second = daysec - hour*3600 - minute*60;
vtime = cdiEncodeTime(hour, minute, second);
*rvdate = vdate;
*rvtime = vtime;
}
void splitTimevalue(double timevalue, int timeunit, int *date, int *time)
{
static char func[] = "splitTimevalue";
......@@ -1223,32 +1245,19 @@ void splitTimevalue(double timevalue, int timeunit, int *date, int *time)
int daysec;
static int lwarn = TRUE;
if ( timeunit == TUNIT_HOUR )
if ( timeunit == TUNIT_SECOND )
{
timevalue /= 86400;
conv_timeval(timevalue, &vdate, &vtime);
}
else if ( timeunit == TUNIT_HOUR )
{
timevalue /= 24;
vdate = (int) timevalue;
if ( vdate < 0 )
daysec = (int) (-(timevalue - vdate)*86400 + 0.01);
else
daysec = (int) ( (timevalue - vdate)*86400 + 0.01);
hour = daysec / 3600;
minute = (daysec - hour*3600)/60;
second = daysec - hour*3600 - minute*60;
vtime = cdiEncodeTime(hour, minute, second);
conv_timeval(timevalue, &vdate, &vtime);
}
else if ( timeunit == TUNIT_DAY )
{
vdate = (int) timevalue;
if ( vdate < 0 )
daysec = (int) (-(timevalue - vdate)*86400 + 0.01);
else
daysec = (int) ( (timevalue - vdate)*86400 + 0.01);
hour = daysec / 3600;
minute = (daysec - hour*3600)/60;
second = daysec - hour*3600 - minute*60;
vtime = cdiEncodeTime(hour, minute, second);
conv_timeval(timevalue, &vdate, &vtime);
}
else if ( timeunit == TUNIT_MONTH )
{
......
Supports Markdown
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