This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Mary, >Date: Mon, 18 Oct 2004 17:42:01 -0600 (MDT) >From: Mary Haley <address@hidden> >To: Steve Emmerson <address@hidden> >Subject: Re: 20041015: Bug in ut_calendar? The above message contained the following: > I tried this new version, and it worked on the case where time=0. But, > it exhibits strange results for time = 1,2, etc. I've > attached a new program that shows this. > > Can you try this on your version of Udunits? > > thanks, > > --Mary ... > #include <stdio.h> > #include <udunits.h> > > void main() > { > int utret; > int utopen(); > utUnit unit; > > double time[5] = {0.,1.,2.,3.,4.}; > int i, year, month, day, hour, minute; > char *units = "months since 1870-1-1"; > float second; > > utret = utInit("udunits.dat"); > (void)utScan(units, &unit); > > for(i = 0; i < 5; i++ ) { > (void) utCalendar(time[i],&unit,&year,&month,&day, > &hour,&minute,&second); > > printf("units = '%s'\n",units); > printf("time = %g\n", time[i]); > printf("year = %d\n", year); > printf("month = %d\n", month); > printf("day = %d\n", day); > printf("hour = %d\n", hour); > printf("second= %g\n", second); > printf("\n"); > } > > utTerm(); > } I get the following from the above program: units = 'months since 1870-1-1' time = 0 year = 1870 month = 1 day = 1 hour = 0 second= 0 units = 'months since 1870-1-1' time = 1 year = 1870 month = 1 day = 31 hour = 10 second= 3.83122 units = 'months since 1870-1-1' time = 2 year = 1870 month = 3 day = 2 hour = 20 second= 7.66245 units = 'months since 1870-1-1' time = 3 year = 1870 month = 4 day = 2 hour = 7 second= 11.4937 units = 'months since 1870-1-1' time = 4 year = 1870 month = 5 day = 2 hour = 17 second= 15.3249 This seems correct to me. Are you thinking that a "month" is a variable unit (i.e., is a variable amount of time)? Regards, Steve Emmerson