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

[UDUNITS #JLQ-522131]: udunits2 and utScan, utIsTime

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.


  • Subject: [UDUNITS #JLQ-522131]: udunits2 and utScan, utIsTime
  • Date: Thu, 18 Oct 2007 17:03:32 -0600

Sue,

> Sorry for the trouble in advance:
> 
> Units that are CF compliant for time like the
> entire string "seconds since 1970-01-01T00:00:00Z"
> is going to fail to produce in a true  in the following line.
> 
> if (ut_are_convertible(unit, ut_get_unit_by_name(system, "second")) {
> ...
> }
> 
> So if testing units is the only way to detect a time coordinate variable,
> I dont see how it can be done.

Then test for convertibility against a timestamp unit:

    ut_system system = ut_read_xml(NULL);
    ut_unit timestampUnit = ut_offset_by_time(ut_get_by_name(system, "second"), 
0);
    ut_testUnit = ...
    if (ut_are_convertible(testUnit, timestampUnit)) {
        ...
    }
Regards,
Steve Emmerson

Ticket Details
===================
Ticket ID: JLQ-522131
Department: Support UDUNITS
Priority: Normal
Status: Closed