[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[UDUNITS #CVV-877033]: UDUNITS2 and utCalendar
- Subject: [UDUNITS #CVV-877033]: UDUNITS2 and utCalendar
- Date: Mon, 04 Jan 2010 08:43:22 -0700
Rosalyn,
> The units of a netcdf(CF) time variable must contain a reference time.
>
> E.g units = "days since 1970-01-01 00:00:00" [ Valid time units and
> reference time]
> utScan told me this was a valid unit and I used utCalendar to convert it
> into a UTC-referenced time. If conversion is successful it tells me the
> reference time was ok.
>
> E.g units="days" [Valid time units, but invalid/no reference time]
> utScan validates the time unit, but since there is no reference time,
> utCalendar fails indicating invalid/no reference time.
>
> So I'm hoping there is another way to do this in UDUNITS2?
Piece of cake. Just test if the "unit" in question is convertible with a known
timestamp "unit". For example:
#include <udunits2.h>
...
ut_system* system = ut_read_xml(NULL);
ut_unit* secsSinceEpoch = ut_parse(system, "seconds since 1970-01-01",
UT_ASCII);
...
ut_unit* testUnit = ...;
if (!ut_are_convertible(secsSinceEpoch, testUnit)) {
/* "testUnit" isn't a timestamp-unit */
}
else {
...
}
And Happy New Year!
> Thanks.
>
> Regards,
> Rosalyn.
> ------------------------------------------------------------------------
> Rosalyn Hatcher
> NCAS Computational Modelling Services
> Dept. of Meteorology, University of Reading,
> Earley Gate, Reading. RG6 6BB
> Email: address@hidden Tel: +44 (0) 118 378 6016
Regards,
Steve Emmerson
Ticket Details
===================
Ticket ID: CVV-877033
Department: Support UDUNITS
Priority: Normal
Status: Closed