Status: New
Owner: [email protected]
Labels: Type-Defect Priority-Medium

New issue 324 by Grigand: Feature: Add a new primitive type for a DateTime format
http://code.google.com/p/protobuf/issues/detail?id=324

Problem Statement:

Protobuffers is lacking in one major way: Date/Time support. Without a defined standard way of transporting date+time information, we are left with inventing our own. Then we are required to document how this data is stored/interpreted. This makes for an ugly public API when 99% of the interchange format is well defined, and 1% is not.

Frankly it's getting very painful, especially when we use proto-buffers to define our wire format and convert these proto structures to json/bson/xml. Both bson and xml require knowledge that the field is of type date+time. Json, unfortunately, is in the same boat protobuffers is, and the current 'hack' is using new Date(...). While writing these various formats we are currently in the position of defining date+time as an Int64 and recognizing it by the field name suffix 'RawDateTime'. Lots of ugly code, but I think you get the idea of why this is important.

Solution(s):

I am told google transmits date+time as an Int64 offset from the unix epoch (00:00:00 UTC on 1 January 1970). This would be more than sufficient for most uses. I also admit there is a whole 'bag of worms' that goes along with date+time. I'm not interested in solving world hunger, but a simple, well defined, standard date+time format is a must for many projects. I really don't care what standard is used, anything is better than nothing at this point ;)

If you really want to overkill the problem ...

struct DateTime64
{
    union {
        struct {
            sint64 Year      : 16;  // +/-32767  (16 bits)
            uint64 Month     : 4;   // 1~12      (20 bits)
            uint64 Day       : 5;   // 1~31      (25 bits)

            uint64 Hour      : 5;   // 0~23      (30 bits)
            uint64 Minute    : 6;   // 0~59      (36 bits)
            uint64 Second    : 6;   // 0~59      (42 bits)
            uint64 Milli     : 10;  // 0~999     (52 bits)

uint64 IsDST : 1; // 0~1 (53 bits) - Daylight Saving Time sint64 UtcOffset : 11; // -720~840 (64 bits) - UTC offset minutes
        } ;
        uint64 Int64;
    };
};



--
You received this message because you are subscribed to the Google Groups "Protocol 
Buffers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to