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.
Henry, > Hi there I have been trying to convert > FROM "734662 days since 1-1-1 00:00:0.0" TO "2012-06-07 00:00:0.0" > OR > FROM "734669.5 days since 1-1-1 00:00:0.0 TO "2012-06-14 > 12:00:0.0" > > It not very obvious how to achieve this with udunits2. > Is this conversion possible ? Assuming you want to perform the conversion programatically: ut_system unitSystem = ut_read_xml(NULL); ut_unit fromUnit = ut_parse(unitSystem, "734662 days since 1-1-1 00:00:0.0", UT_ASCII); ut_unit toUnit = ut_parse(unitSystem, "days since 2012-06-07 00:00:0.0", UT_ASCII); cv_converter converter = ut_get_converter(fromUnit, toUnit); double fromValue = ...; double toValue = cv_convert_double(converter, fromValue); Note that, due the change in calendars from Julian to Gregorian, converting values from a "unit" that's referenced to 1-1-1T00:00:00 to one that referenced to a contemporary time can be problematical. Neither UDUNITS package was intended for rigorous calendar conversions. For that you should use a package intended for that purpose. > Many thanks > .. Henry Regards, Steve Emmerson Ticket Details =================== Ticket ID: CNF-843793 Department: Support UDUNITS Priority: Normal Status: Closed