Open benjwadams opened 21 hours ago
Milliseconds is the most fine grained time measurement currently supported in ERDDAP. https://github.com/ERDDAP/erddap/blob/main/WEB-INF/classes/com/cohort/util/Calendar2.java#L5741-L5770
This is surprising behavior because UDUNITS2 allows for all the way down to yocto (10^-24) prefixes on units: https://github.com/Unidata/UDUNITS-2/blob/c83da987387db1174cd2266b73dd5dd556f4476b/lib/udunits2-prefixes.xml#L74
While it's unlikely that the sort of data ERDDAP Is usually serving would have this fine of a time resolution, it is nonetheless, to the best of my knowledge, valid in UDUNITS2 to express something like yoctoseconds since 2024-01-01+00:00
.
An acceptable enough fix would be to parse that unit and switch/case a power of ten multiplier to convert the relative time prefix back to milli(time interval) in the event that the Java calendar library threw an an exception.
The ERDDAP documentation for handling time units is here: https://erddap.github.io/setupDatasetsXml.html#timeUnits
It doesn't strictly follow UDUNITS2. ERDDAP doesn't use UDUNITS2 for time conversions. Adding additional time units (even just for time conversion) is possible but more work than a power of ten conversion in one spot. Additionally in several places the java.util.Date library is still used which only has millisecond precision. To properly support nanoseconds we'd need to update that code to a different library or verify it doesn't need the additional precision. Past nanosecond accuracy and standard java time libraries don't support that. Power of ten conversion only support might be possible, but I wonder how beneficial that is, especially if users don't realize they are loosing the precision they think they have.
Describe the bug Conversion from relative time units containing nanoseconds causes an exception when attempting to convert in ERDDAP's internal routines.
To Reproduce Steps to reproduce the behavior: 1) Add a dataset with time
units
attribute set to something withnanoseconds
, e.g.nanoseconds since 1970-01-01T00:00:00+00:00
. 2) Add dataset todatasets.xml
to be inventoried by ERDDAP. 3) Dataset does not appear and a Java calendar exception is raised in the ERDDAP log file.Excerpt from email correspondence where this issue was encountered:
I have yet to encounter or test any datasets with even smaller time intervals such as picoseconds, but I imagine this issue may also exist with them.
Expected behavior Relative time units expressed in nanoseconds ("nanoseconds since 1970-01-01T00:00:00+00:00") converts properly since it should be a valid UDUnits relative time.
Server
Desktop (please complete the following information):
Additional context Add any other context about the problem here.