[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[UDUNITS #OTA-964622]: udunits2 error message



Ajit,

> (1)In testUnits.c :
> second = ut_new_base_unit(unitSystem);
> CU_ASSERT_PTR_NOT_NULL(second);
> CU_ASSERT_PTR_NULL(ut_offset_by_time(second,
> ut_encode_time(1970, 1, 1, 0, 0, 0)));
> CU_ASSERT_EQUAL(ut_get_status(), UT_NO_SECOND);
> 
> My modified test  without CUnit calls:
> ut_unit *second = ut_new_base_unit(unitSystem);
> if (second == NULL)
> printf("Error\n");  // This is NOT printed

Correct.

> if (ut_offset_by_time(second, ut_encode_time(1970, 1, 1, 0, 0, 0)) == NULL)
> printf("Error\n");  // This is printed

The above isn't an error: under these conditions, ut_encode_time() should
return NULL.

> if (ut_get_status() != UT_NO_SECOND)
> printf("Error\n");  // This is printed

It shouldn't be. What is the value returned by ut_get_status()?

> The second and third errors are printed.
> 
> I’m using the same checking conditions as in the CU tests

Not quite.

> so my inference is that this is not working.
> 
> Am I mistaken?

See my responses above.

> (2)With udunits-1 I could do this :
> float second;
> double val = 1095.0;
> int year, year2, month, day, hour, minute;
> utIni(&unit);
> if (stat = utScan("days since 1895-01-01", &unit) == 0)
> {
> if (stat = utIsTime(&unit) == 1)
> {
> year2 = 1900;
> utCalendar(val, &unit, &year, &month, &day, &hour, &minute, &second);
> printf("%lf = %d/%d/%d %d:%d:%f\n", val, month, day, year, hour, minute, 
> second);
> utInvCalendar(year2, month, day, hour, minute, second, &unit, &val);
> printf("%d/%d/%d %d:%d:%f = %lf\n", month, day, year2, hour, minute, second, 
> val);
> }
> }
> 
> I looked through the supplied docs, links and help pages for udunits2 and did 
> not see any help on how I could achieve the above
> 
> Basically I want to parse a string like “days since 1895-01-01”, then convert 
> a value to date and a date to value
> 
> Can you guide me on how I can do a similar thing using udunits2?

You're right. There doesn't appear to be a way to do that in the UDUNITS-2
package. An oversight on my part.

I'll see about adding that capability.

Regards,
Steve Emmerson

Ticket Details
===================
Ticket ID: OTA-964622
Department: Support UDUNITS
Priority: Normal
Status: Closed
===================
NOTE: All email exchanges with Unidata User Support are recorded in the Unidata 
inquiry tracking system and then made publicly available through the web.  If 
you do not want to have your interactions made available in this way, you must 
let us know in each email you send to us.