On 03 Jun 2015, at 16:57, Ben Coman <btc@openinworld.com> wrote:
On Wed, Jun 3, 2015 at 8:36 PM, Sven Van Caekenberghe <sven@stfx.eu> wrote:
On 03 Jun 2015, at 04:20, Esteban A. Maringolo <emaringolo@gmail.com> wrote:
I'm debugging the PostgresV3 driver for GLORP, and among other test failures, there is a kind that particularly bugs me: two identical dates do not match, the reason? The internal "start" of aDate (Timespan) is a DateAndTime, and as such has a timezone offset.
Is this conceptually right?
Esteban A. Maringolo
Yes, it is bit annoying and weird, but it all does make sense as well.
The concept of a date cannot be seen independent from a timezone (day transitions are different for you than for me, new year starts at different moments depending on where you live). Defining a Date as the timespan of one day starting at a specific moment in time is correct.
I've observed several of date/time discussions that I didn't really follow all the details, but my first thought here is that Date, Time, and DateAndTime are three separate concepts. Shouldn't timezones only affect comparing dates if you are calculating the hours between dates? Adding the concept of "starting at a specific moment in time" would seem to turn a Date into a DateAndTime, which is the point where timezones should have an impact.
Currently: Date is a Timespan of 24h starting at a specific, universally unique point in time (a DateAndTime). You can ask it things like when did you begin, end, do you contain t. Other, more abstract notions of a Date are possible, of course, but that is not what we have.
For example, if you are reading a date "dd/mm/yyyy" from some database field, what timezone do you assign?
That is indeed the (original) problem. But even dd/mm/yyyy in some random DB or somewhere on the internet implies a timezone, else it does not make (enough/total) sense. Again, your date today is not equal to mine, at some point in time we are in different days, it is that simple.
cheers -ben
One thing you could try is to make the starting time UTC, a bit like
Date today translateToUTC.
DateAndTime now asUTC asDate.
But I am not sure how much of your problems this would solve.
Sven