[gdal-dev] Parse ISO 8601 formatted timestamps

Frank Warmerdam warmerdam at pobox.com
Wed Jul 2 07:01:24 EDT 2008


Maarten Plieger wrote:
> Hi,
> 
> Are there existing functions in GDAL to parse ISO 8601 formatted 
> timestamps?
> I would like to convert a string of the form YYYYMMDDThhmmss.ss to a 
> juliandate and back.

Maarten,

GDAL/OGR has no support (I am aware of) for Julian dates.  Most textual
parsing for OGR is encapsulated in the OGRParseDate() function with docs
looking like:


/**
  * Parse date string.
  *
  * This function attempts to parse a date string in a variety of formats
  * into the OGRField.Date format suitable for use with OGR.  Generally
  * speaking this function is expecting values like:
  *
  *   YYYY-MM-DD HH:MM:SS+nn
  *
  * The seconds may also have a decimal portion (which is ignored).  And
  * just dates (YYYY-MM-DD) or just times (HH:MM:SS) are also supported.
  * The date may also be in YYYY/MM/DD format.  If the year is less than 100
  * and greater than 30 a "1900" century value will be set.  If it is less than
  * 30 and greater than -1 then a "2000" century value will be set.  In
  * the future this function may be generalized, and additional control
  * provided through nOptions, but an nOptions value of "0" should always do
  * a reasonable default form of processing.
  *
  * The value of psField will be indeterminate if the function fails (returns
  * FALSE).
  *
  * @param pszInput the input date string.
  * @param psField the OGRField that will be updated with the parsed result.
  * @param nOptions parsing options, for now always 0.
  *
  * @return TRUE if apparently successful or FALSE on failure.
  */

int OGRParseDate( const char *pszInput, OGRField *psField, int nOptions )

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGeo, http://osgeo.org



More information about the gdal-dev mailing list