On 2015-04-05 16:25, Even Rouault wrote:
    struct {
        GInt16  Year;
        GByte   Month;
        GByte   Day;
        GByte   Hour;
        GByte   Minute;
        GByte   TZFlag; 
        GByte   Precision; /* value in OGRDateTimePrecision */
        float   Second; /* from 00.000 to 60.999 (millisecond accuracy) */
    } Date;
If it's not too different from what exists, I have found that a good general solution is what Unix uses:

struct {
    GInt64  second;      /* assuming GInt64 and GUInt32 types exist */
    GUInt32 nanosecond;
} Date;

This representation is good for nearly 300-billion years with uniform resolution of one nanosecond.  Don't take the evolutionary path of repeatedly discovering that you don't have enough precision and just jump straight to nanoseconds.  Time zones don't matter either; just represent everything in UTC and display it in the local time zone of the client (using POSIX localtime_r() which is compatible with this representation).  Parsing strings isn't a big problem either; I've written code that can parse a packed-digit string like "20150405193638" into this structure in 27 nanoseconds on a computer that is several years old (by comparison, a simple string copy of the same string takes 25 nanoseconds). Date arithmetic and comparison is also very simple.  You can add the 'Precision' field if you need it.

--
Dr. Craig S. Bruce
Senior Software Developer
CubeWerx Inc.

_______________________________________________
gdal-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to