CLSQL Wall-Time - Timestamptz vs Timestamp issues

"Russ Tyndall" <[email protected]> Tue, 6 Feb 2018 11:52:31 -0500
Newsgroups gmane.lisp.clsql.general
Message-ID <328CF97C48DE43839C20AE49CD544FFD.MAI@mailproc1.me.acceleration.net>
This is a multi-part message in MIME format.

--===============2444896238834481206==
Content-Type: multipart/alternative;
	boundary="__=_AltPart_1468672757_711830908"

This is a multi-part message in MIME format.

--__=_AltPart_1468672757_711830908
Content-Type: text/plain;
	charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Howdy CLSQL,

I have created a patch to better distinguishing between zoneless
timestamps and UTC times, particularly as relates to
postgresql-socket3 backend. Without this change, `timestamptz`s are
read as localtimes and saved as localtimes, when they should be read
and printed as UTC times - which leads to those fields cursoring
(incrementing by offset) because they are continuously reconvert to
UTC from localtimes. I followed a minimal approach (following
postgresql' lead), of simply adding an is-utc=3F boolean to the
wall-time object. Previously zoned times were converted to UTC, but
since we didn't track that they were indistinguishable from unzoned
times after conversion.

In order to preserver comparability between dates and times that are
local vs UTC, I have added a `time-to-utc` function that is called
on-the-fly during comparisons.  I feel like this minimal approach gets
us 95% of the way toward a non-buggy timezone implementation. I doubt
that this covers *every* possible situation due to the complexity of
timezones.

I verified the math using the local-time libary in a manually loaded
test file: tests/utc-time-compare. (Originally I had based the code
off of local-time, but then found how to do it using
decode-universal-time).

I added two variables *default-timezone* and *default-timezone-is-dst=3F*
these are not exported and only used for testing currently, but could
be exported if there was a good external use case.

https://github.com/UnwashedMeme/clsql/tree/timestamp-utc

Kevin, I have also pushed this branch to your repo (at
timestamp-utc-no-localtime, timestamp-utc was a previous version using
local-time and I couldnt overwrite it). If you like, please feel free
to merge and increment, otherwise please comment and help me move
forward with better timezone support.  Thanks for your work!


Cheers,
Russ Tyndall
Acceleration.net


--__=_AltPart_1468672757_711830908
Content-Type: text/html;
	charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Howdy CLSQL,<br/><br/>I have created a patch to better distinguishing betwe=
en zoneless<br/>timestamps and UTC times, particularly as relates to<br/=
>postgresql-socket3 backend. Without this change, `timestamptz`s are<br/=
>read as localtimes and saved as localtimes, when they should be read<br=
/>and printed as UTC times - which leads to those fields cursoring<br/>(=
incrementing by offset) because they are continuously reconvert to<br/>U=
TC from localtimes. I followed a minimal approach (following<br/>postgre=
sql' lead), of simply adding an is-utc=3F boolean to the<br/>wall-time o=
bject. Previously zoned times were converted to UTC, but<br/>since we di=
dn't track that they were indistinguishable from unzoned<br/>times after=
 conversion.<br/><br/>In order to preserver comparability between dates =
and times that are<br/>local vs UTC, I have added a `time-to-utc` functi=
on that is called<br/>on-the-fly during comparisons.  I feel like this m=
inimal approach gets<br/>us 95% of the way toward a non-buggy timezone i=
mplementation. I doubt<br/>that this covers *every* possible situation d=
ue to the complexity of<br/>timezones.<br/><br/>I verified the math usin=
g the local-time libary in a manually loaded<br/>test file: tests/utc-ti=
me-compare. (Originally I had based the code<br/>off of local-time, but =
then found how to do it using<br/>decode-universal-time).<br/><br/>I add=
ed two variables *default-timezone* and *default-timezone-is-dst=3F*<br/=
>these are not exported and only used for testing currently, but could<b=
r/>be exported if there was a good external use case.<br/><br/>https://g=
ithub.com/UnwashedMeme/clsql/tree/timestamp-utc<br/><br/>Kevin, I have a=
lso pushed this branch to your repo (at<br/>timestamp-utc-no-localtime, =
timestamp-utc was a previous version using<br/>local-time and I couldnt =
overwrite it). If you like, please feel free<br/>to merge and increment,=
 otherwise please comment and help me move<br/>forward with better timez=
one support.  Thanks for your work!<br/><br/><br/>Cheers,<br/>Russ Tynda=
ll<br/>Acceleration.net<br/><br/>
--__=_AltPart_1468672757_711830908--

--===============2444896238834481206==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline

X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KQ0xTUUwgbWFp
bGluZyBsaXN0CkNMU1FMQGxpc3RzLmtwZS5pbwpodHRwOi8vbGlzdHMua3BlLmlvL2NnaS1iaW4v
bWFpbG1hbi9saXN0aW5mby9jbHNxbAo=

--===============2444896238834481206==--