[gdal-dev] New config option for date/time output
Ari Jolma
ari.jolma at gmail.com
Tue Mar 15 07:04:40 PDT 2016
15.03.2016, 15:59, Joaquim Luis kirjoitti:
> On Tue, 15 Mar 2016 13:01:29 -0000, Ari Jolma <ari.jolma at gmail.com>
> wrote:
>
>> 15.03.2016, 14:08, Joaquim Luis kirjoitti:
>>> GMT uses "yyy-mm-ddT[hh:mm:ss] (Gregorian) or yyyy-Www-ddT[hh:mm:ss]
>>> (ISO)"
>>>
>>> http://gmt.soest.hawaii.edu/doc/latest/gmt.conf.html#calendar-time-parameters
>>> It would be nice to use the same.
>>
>> I'm not sure I understand you correctly but strftime can do this:
>>
>> OGR_DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%S"
>>
>> gives for example 2016-01-10T08:25:12 and
>>
>> OGR_DATETIME_FORMAT = "%Y-%W-%dT%H:%M:%S"
>>
>> gives 2016-01-10T08:25:12 for the same time - 10.1.2016 is on week
>> two (strftime: %W = Week number with the first Monday as the first
>> day of week one (00-53))
>
> Sorry, it was me who misunderstood your question/suggestion. I thought
> that printing with the above format was not possible yet and that's
> why I pointed to what GMT does. But if GDAL can do it already, than
> sorry for the noise.
It can't. That's why I'm suggesting this. The core of my suggestion is
to start using the strftime function and the config options.
I've actually implemented it already for testing, that's why I may sound
like that GDAL can do it already.
Cheers,
Ari
>
> Joaquim
>
>> I think that there needs to be separate options for date and
>> datetime, i.e., OGR_DATE_FORMAT and OGR_DATETIME_FORMAT.
>>
>> Ari
>>
>>>
>>> Joaquim
>>>
>>>> Folks,
>>>>
>>>> The OGRFeature::GetFieldAsString returns date/time fields formatted
>>>> in non-standard way. For example date is output as "year/month/day"
>>>> as more usual "year-month-day". This causes problems in many programs.
>>>>
>>>> I suggest adding a new config option OGR_DATE_FORMAT, which, if
>>>> set, would make the method return date/time formatted according to
>>>> it. I suggest that we use the strftime and its format argument as
>>>> the target for the new option.
>>>>
>>>> The implementation is complicated a bit when milliseconds and
>>>> timezones are involved since they are not included in the struct tm
>>>> used by strftime. I suggest that we assume seconds are formatted as
>>>> :\d\d in the format and simply add milliseconds (as .\d\d\d) and
>>>> timezone (as [+-]\d\d(:\d\d)), if they exists, after the second.
>>>>
>>>> Do you think this needs a RFC?
>>>>
>>>> I'm willing to implement the changes.
>>>>
>>>> Ari
>>>>
>>>> _______________________________________________
>>>> gdal-dev mailing list
>>>> gdal-dev at lists.osgeo.org
>>>> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>>> _______________________________________________
>>> gdal-dev mailing list
>>> gdal-dev at lists.osgeo.org
>>> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>>
>> _______________________________________________
>> gdal-dev mailing list
>> gdal-dev at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/gdal-dev
More information about the gdal-dev
mailing list