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

[UDUNITS #YIK-340868]: How to convert TimeStamps to Dates



Samuel,

Does CALPAK allow you to create a timestamp object from a year, month, day, 
hour, minute, and second?

Does CALPAK allow you to add an arbitrary time interval to the timestamp object 
and get a new timestamp object?

If the answer to both questions is yes, then you can do this:

    1. Create a reference CALPAK timestamp object using an arbitary time;
    2. Parse the netCDF unit into a binary UDUNITS-2 unit;
    3. Parse a reference offset from the reference CALPAK time into a binary 
UDUNITS-2 unit;
    4. Obtain a UDUNITS-2 converter from the netCDF binary unit to the CALPAK 
binary unit; and
    5. For each netCDF time-coordinate value:
        a. Convert the time-coordinate value from the netCDF unit to the CALPAK 
unit;
        b. Add the converted value to the reference CALPAK timestamp object to 
obtain a new CALPAK timestamp object; and
        c. Have CALPAK convert the new timestamp object into a string.

> Hello Steve,
> I understand that UDUnits is not a calendar library and I'm using calpak
> for this. I have a std C&F dataset file that specify a time axis with a
> timstamp unit such as "hours since 1950-01-01 00:00:0.0" and a vector of
> data with the hours since 1950.
> Now, I cannot find a way to get the epoch from the ut_unit object to do
> the convertion with calpak nor a way to convert the hours to an absolute
> date with whatever calendar is included in the library.
> How shall I convert/decode hours to a vector of absolute date ?
> Regards,
> Samuel Debionne

Regards,
Steve Emmerson

Ticket Details
===================
Ticket ID: YIK-340868
Department: Support UDUNITS
Priority: Normal
Status: Closed