Algo-Web / POData

OData for Poor PHP Devs
Other
28 stars 13 forks source link

Configurable date format #249

Open kirill533 opened 4 years ago

kirill533 commented 4 years ago

OData clients/servers deliver date differently. For example, https://services.odata.org/OData/OData.svc/Products deivers field "updated" like this: <updated>2020-05-07T12:41:26Z</updated> .

In case of Power BI, it works if the format of the date will be done the following way:

JsonWriter::writeValue

                $dateTime = new \DateTime($value, new \DateTimeZone('UTC'));
                $formattedDateTime = $dateTime->format('Y-m-d\TH:i:s');
                $this->writeCore($formattedDateTime, /* quotes */ true);

Current implementation in master is:

                $dateTime          = new \DateTime($value, new \DateTimeZone('UTC'));
                $formattedDateTime = $dateTime->format('U')*1000;
                $this->writeCore('/Date(' . $formattedDateTime . ')/', /* quotes */ true);

Could you please make it configurable?

c-harris commented 4 years ago

I would be happy to make it configurable (Now that we fixed the config) probably defaulting to the ABNF

dateTimeBody = year "-" month "-" day "T" hour ":" minute [ ":" second [ "." nanoSeconds ] ] year = 4*DIGIT; month = zeroToTwelve day = zeroToThirtyOne hour = zeroToTwentyFour minute = zeroToSixty second = zeroToSixty nanoSeconds = 1*7DIGIT

But i will probably also be kicking it down the road to after we finish #243

kirill533 commented 4 years ago

Sure, I was also thinking about that new configurator. This is not a high prio item, just a small item to come closer to the merge of our repos.

c-harris commented 4 years ago

Just tack then on as you come across them and we will do what I can.