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

change encode/decode_time to seconds

parent a7d249e6
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for cdi 1.3.3.
# Generated by GNU Autoconf 2.61 for cdi 1.4.0.
#
# Report bugs to <Uwe.Schulzweida@zmaw.de>.
#
......@@ -574,8 +574,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='cdi'
PACKAGE_TARNAME='cdi'
PACKAGE_VERSION='1.3.3'
PACKAGE_STRING='cdi 1.3.3'
PACKAGE_VERSION='1.4.0'
PACKAGE_STRING='cdi 1.4.0'
PACKAGE_BUGREPORT='Uwe.Schulzweida@zmaw.de'
# Factoring default headers for most tests.
......@@ -1229,7 +1229,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures cdi 1.3.3 to adapt to many kinds of systems.
\`configure' configures cdi 1.4.0 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
......@@ -1300,7 +1300,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of cdi 1.3.3:";;
short | recursive ) echo "Configuration of cdi 1.4.0:";;
esac
cat <<\_ACEOF
......@@ -1411,7 +1411,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
cdi configure 1.3.3
cdi configure 1.4.0
generated by GNU Autoconf 2.61
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
......@@ -1425,7 +1425,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by cdi $as_me 1.3.3, which was
It was created by cdi $as_me 1.4.0, which was
generated by GNU Autoconf 2.61. Invocation command line was
$ $0 $@
......@@ -2252,7 +2252,7 @@ fi
# Define the identity of the package.
PACKAGE='cdi'
VERSION='1.3.3'
VERSION='1.4.0'
cat >>confdefs.h <<_ACEOF
......@@ -7263,7 +7263,7 @@ exec 6>&1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by cdi $as_me 1.3.3, which was
This file was extended by cdi $as_me 1.4.0, which was
generated by GNU Autoconf 2.61. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
......@@ -7316,7 +7316,7 @@ Report bugs to <bug-autoconf@gnu.org>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
cdi config.status 1.3.3
cdi config.status 1.4.0
configured by $0, generated by GNU Autoconf 2.61,
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
......
# Process this file with autoconf to produce a configure script.
AC_INIT(cdi, 1.3.3, Uwe.Schulzweida@zmaw.de)
AC_INIT(cdi, 1.4.0, Uwe.Schulzweida@zmaw.de)
echo "configuring ${PACKAGE_NAME} ${PACKAGE_VERSION}"
......
......@@ -163,7 +163,8 @@ int calday_to_date(int calendar, int calday)
}
void encode_caldaysec(int calendar, int year, int month, int day, int hour, int minute, int *julday, int *secofday)
void encode_caldaysec(int calendar, int year, int month, int day, int hour, int minute, int second,
int *julday, int *secofday)
{
int dpy;
......@@ -174,11 +175,12 @@ void encode_caldaysec(int calendar, int year, int month, int day, int hour, int
else
*julday = encode_julday(calendar, year, month, day);
*secofday = (hour*60 + minute)*60;
*secofday = hour*3600 + minute*60 + second;
}
void decode_caldaysec(int calendar, int julday, int secofday, int *year, int *month, int *day, int *hour, int *minute)
void decode_caldaysec(int calendar, int julday, int secofday,
int *year, int *month, int *day, int *hour, int *minute, int *second)
{
int dpy;
......@@ -191,6 +193,7 @@ void decode_caldaysec(int calendar, int julday, int secofday, int *year, int *mo
*hour = secofday/3600;
*minute = secofday/60 - *hour*60;
*second = secofday - *hour*3600 - *minute*60;
}
......@@ -210,7 +213,7 @@ int main(void)
nmin = 11000;
vdate0 = -80001201;
vtime0 = 1205;
vtime0 = 120500;
printf("start time: %8d %4d\n", vdate0, vtime0);
......@@ -295,27 +298,27 @@ int main(void)
int calendar = CALENDAR_STANDARD;
int i;
int calday, secofday;
int year, month, day, hour, minute;
int year, month, day, hour, minute, second;
int value = 30;
int factor = 86400;
calendar = CALENDAR_360DAYS;
year=1979; month=1; day=15; hour=12; minute=30;
year=1979; month=1; day=15; hour=12; minute=30; second = 0;
printf("calendar = %d\n", calendar);
printf("%d/%02d/%02d %02d:%02d\n", year, month, day, hour, minute);
printf("%d/%02d/%02d %02d:%02d:%02d\n", year, month, day, hour, minute, second);
encode_caldaysec(calendar, year, month, day, hour, minute, &calday, &secofday);
encode_caldaysec(calendar, year, month, day, hour, minute, second, &calday, &secofday);
decode_caldaysec(calendar, calday, secofday, &year, &month, &day, &hour, &minute);
printf("%d/%02d/%02d %02d:%02d %d %d\n", year, month, day, hour, minute, calday, secofday);
decode_caldaysec(calendar, calday, secofday, &year, &month, &day, &hour, &minute, &second);
printf("%d/%02d/%02d %02d:%02d:%02d %d %d\n", year, month, day, hour, minute, second, calday, secofday);
for ( i = 0; i < 420; i++ )
{
decode_caldaysec(calendar, calday, secofday, &year, &month, &day, &hour, &minute);
printf("%2d %d/%02d/%02d %02d:%02d\n", i, year, month, day, hour, minute);
decode_caldaysec(calendar, calday, secofday, &year, &month, &day, &hour, &minute, &second);
printf("%2d %d/%02d/%02d %02d:%02d:%02d\n", i, year, month, day, hour, minute, second);
julday_add_seconds(value*factor, &calday, &secofday);
}
......
#ifndef _CALENDAR_H
#define _CALENDAR_H
void encode_caldaysec(int calendar, int year, int month, int day, int hour, int minute, int *julday, int *secofday);
void decode_caldaysec(int calendar, int julday, int secofday, int *year, int *month, int *day, int *hour, int *minute);
void encode_caldaysec(int calendar, int year, int month, int day, int hour, int minute, int second,
int *julday, int *secofday);
void decode_caldaysec(int calendar, int julday, int secofday,
int *year, int *month, int *day, int *hour, int *minute, int *second);
#endif /* _CALENDAR_H */
......@@ -184,8 +184,10 @@ static int splitBasetime(char *timeunits, TAXIS *taxis)
{
ptu++;
second = atoi(ptu);
/*
if ( second != 0 )
Message(func, "Seconds not supported in time units!");
*/
}
}
}
......
......@@ -334,7 +334,7 @@ int taxisID;
taxisID = taxisCreate(TAXIS_RELATIVE);
taxisDefCalendar(taxisID, CALENDAR_STANDARD);
taxisDefRdate(taxisID, 19870101);
taxisDefRtime(taxisID, 1200);
taxisDefRtime(taxisID, 120000);
...
@EndSource
@EndFunction
......@@ -458,7 +458,7 @@ void taxisDefVdate(int taxisID, int vdate)
@Prototype void taxisDefVtime(int taxisID, int vtime)
@Parameter
@Item taxisID Time axis ID, from a previous call to @fref{taxisCreate}
@Item vtime Verification time (hhmm)
@Item vtime Verification time (hhmmss)
@Description
The function @func{taxisDefVtime} defines the verification time of a Time axis.
......@@ -512,7 +512,7 @@ void taxisDefRdate(int taxisID, int rdate)
@Prototype void taxisDefRtime(int taxisID, int rtime)
@Parameter
@Item taxisID Time axis ID, from a previous call to @fref{taxisCreate}
@Item rtime Reference time (hhmm)
@Item rtime Reference time (hhmmss)
@Description
The function @func{taxisDefVdate} defines the reference time of a Time axis.
......@@ -1040,13 +1040,13 @@ void timeval2vtime(double timevalue, TAXIS *taxis, int *vdate, int *vtime)
}
else
{
encode_caldaysec(calendar, year, month, day, hour, minute, &julday, &secofday);
encode_caldaysec(calendar, year, month, day, hour, minute, second, &julday, &secofday);
decode_timevalue(timeunit, timevalue, &days, &secs);
julday_add(days, secs, &julday, &secofday);
decode_caldaysec(calendar, julday, secofday, &year, &month, &day, &hour, &minute);
decode_caldaysec(calendar, julday, secofday, &year, &month, &day, &hour, &minute, &second);
}
*vdate = encode_date(year, month, day);
......@@ -1079,7 +1079,7 @@ double vtime2timeval(int vdate, int vtime, TAXIS *taxis)
decode_date(rdate, &ryear, &rmonth, &day);
decode_time(rtime, &hour, &minute, &second);
encode_caldaysec(calendar, ryear, rmonth, day, hour, minute, &julday1, &secofday1);
encode_caldaysec(calendar, ryear, rmonth, day, hour, minute, second, &julday1, &secofday1);
decode_date(vdate, &year, &month, &day);
decode_time(vtime, &hour, &minute, &second);
......@@ -1098,7 +1098,7 @@ double vtime2timeval(int vdate, int vtime, TAXIS *taxis)
}
else
{
encode_caldaysec(calendar, year, month, day, hour, minute, &julday2, &secofday2);
encode_caldaysec(calendar, year, month, day, hour, minute, second, &julday2, &secofday2);
julday_sub(julday1, secofday1, julday2, secofday2, &days, &secs);
......@@ -1120,33 +1120,34 @@ void splitTimevalue(double timevalue, int timeunit, int *date, int *time)
int vdate = 0, vtime = 0;
int hour, minute, second;
int year, month, day;
int days, daysec;
static int lwarn = TRUE;
if ( timeunit == TUNIT_HOUR )
{
timevalue /= 24;
vdate = (int) timevalue;
days = (int) timevalue;
if ( vdate < 0 )
vtime = (int) (-(timevalue - vdate)*1440 + 0.01);
daysec = (int) (-(timevalue - days)*86400 + 0.01);
else
vtime = (int) ( (timevalue - vdate)*1440 + 0.01);
daysec = (int) ( (timevalue - days)*86400 + 0.01);
hour = vtime / 60;
minute = vtime - hour*60;
second = 0;
hour = daysec / 3600;
minute = daysec - hour*3600;
second = daysec - hour*3600 - minute*60;
vtime = encode_time(hour, minute, second);
}
else if ( timeunit == TUNIT_DAY )
{
vdate = (int) timevalue;
days = (int) timevalue;
if ( vdate < 0 )
vtime = (int) (-(timevalue - vdate)*1440 + 0.01);
daysec = (int) (-(timevalue - days)*86400 + 0.01);
else
vtime = (int) ( (timevalue - vdate)*1440 + 0.01);
daysec = (int) ( (timevalue - days)*86400 + 0.01);
hour = vtime / 60;
minute = vtime - hour*60;
second = 0;
hour = daysec / 3600;
minute = daysec - hour*3600;
second = daysec - hour*3600 - minute*60;
vtime = encode_time(hour, minute, second);
}
else if ( timeunit == TUNIT_MONTH )
......
......@@ -3,6 +3,8 @@
typedef struct {
/* Date format YYYYMMDD */
/* Time format hhmmss */
int self;
int used;
int type; /* time type */
......
......@@ -32,9 +32,12 @@ int encode_date(int year, int month, int day)
void decode_time(int time, int *hour, int *minute, int *second)
{
*hour = time / 100;
*minute = time - *hour*100;
*second = 0;
int itime;
*hour = time / 10000;
itime = time - *hour*10000;
*minute = itime / 100;
*second = itime - *minute*100;
}
......@@ -42,7 +45,7 @@ int encode_time(int hour, int minute, int second)
{
int time;
time = hour*100 + minute;
time = hour*10000 + minute*100 + second;
return (time);
}
......@@ -159,7 +162,7 @@ int time_to_sec(int time)
decode_time(time, &hour, &minute, &second);
secofday = (hour*60 + minute)*60 + second;
secofday = hour*3600 + minute*60 + second;
return (secofday);
}
......@@ -168,12 +171,13 @@ int time_to_sec(int time)
int sec_to_time(int secofday)
{
int time;
int hour, minute;
int hour, minute, second;
hour = secofday/3600;
minute = secofday/60 - hour*60;
second = secofday - hour*3600 - minute*60;
time = hour*100 + minute;
time = encode_time(hour, minute, second);
return (time);
}
......@@ -261,7 +265,7 @@ int main(void)
nmin = 11000;
vdate0 = -80001201;
vtime0 = 1205;
vtime0 = 120500;
printf("start time: %8d %4d\n", vdate0, vtime0);
......
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