Unidata - To provide the data services, tools, and cyberinfrastructure leadership that advance Earth system science, enhance educational opportunities, and broaden participation. Unidata
         
  advanced  
 

Question about units package...

All,

Below is a snippet of of Perl code that uses UDUNITS to translate a date as it
is stored in our netCDF files to something a human can read.

Digging around in the various examples and docs, I have not been able to figure
out how to do the equivalent using the Java units package.  Can somebody please
provide me with a pointer a specific example or tutorial that covers this?

Thanks,
Roland
-- 
Roland Schweitzer
NOAA-CIRES Climate Diagnostics Center           325 Broadway
NOAA/ERL/CDC - (R/CDC1)                         Boulder, CO 80303
.... (303) 497-6249 .... (303) 497-7013 FAX .... rhs@xxxxxxxxxxxx ....

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

#!/usr/bin/perl -w

use UDUNITS;

   UDUNITS::init('');

   $time_units = "hours since 1700-1-1";

   if ( !($unit = UDUNITS::scan("$time_units"))) {
      print STDERR "Having trouble finding the units for time.\n";
      print STDERR "$time_units is not a valid time unit.\n";
      die;
   }

   $udtim = 2298168.0;

   $unit->valtocal($udtim, $yr, $mon, $day,
                           $hour, $min, $sec);


   print "The time units are $time_units\n";
   print "The encoded time $udtim is $yr-$mon-$day $hour:$min:$sec\n";


 
 
  Contact Us     Site Map     Search     Terms and Conditions     Privacy Policy     Participation Policy
 
National Science Foundation (NSF) UCAR Community Programs   Unidata is a member of the UCAR Community Programs, is managed by the University Corporation for Atmospheric Research, and is sponsored by the National Science Foundation.
P.O. Box 3000     Boulder, CO 80307-3000 USA     Tel: 303-497-8643     Fax: 303-497-8690