-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unsupported timestamp column #16
Comments
For now, I'll just switch to text as the query data format since that works (albeit, not as efficient). Ah, switching to text now gives me incorrect values for my ints.. Ok, back to the drawing board. |
If you use text, is the result output |
Hi Stephan, Yah, I tried that, and it did work for timestamps. But then for all my int columns (id, etc), the string representation was not correct and I couldn't figure out how to get that right. I think the way to go is binary since all the |
I'm mainly interested in what the output that you get for string is, so I can try to correlate it to the binary output. The goal is to have binary implemented for all the different column types. |
Got it. Yes, the text output is |
I can look into full timestamp support this weekend or so. My current trail of thought in case you are interested or want to work on it yourself: You need to swap endianness. PostgreSQL documentation says that timestamps start at 4713 BC. But perhaps your column in fact starts at |
The main problem is – to represent a date with Swift on Linux, we need to add support for https://github.com/apple/swift-corelibs-foundation first to get access to |
Hmm, I played around with a bunch of these permutations over the weekend. I was wondering about the big endian stuff. I also read on some psql list that one dev based his timestamp bytes off 2000-01-01, so if you get microseconds 16 years plus a few days, then that sounds pretty close. Closer than I got. I'll give that a shot. Thx. |
I have a Swift 2.2 (open source, non-xcode) project that I'm trying to get working. For my varchar columns everything is working fine. However, I'm trying to figure out timestamp.
The driver seems to return a integer in bytes. For this timestamp
2016-01-24 15:36:27.223667
I get back a byte array of
[0, 1, 205, 134, 65, 17, 249, 235]
I've tried converting this to a
UInt64
, which I can do via theByteSwap.typeFromByteArray
function. I'm not sure if this is the right approach, tho. I'm assuming that the byte array represents a 64-bit number, but I'm not sure which. For instance, theUInt64
representation of the byte array is17003640841246146816
,Int64
representation is-1443103232463404800
(I definitely don't think it's Int64).Further reading of the postgres docs state that all timestamps are 8-byte Julian dates.
So, my first issue is trying to figure out what data type the byte array is returning back and then second will be getting the Julian date figured out.
Any thoughts on the first? Thanks.
The text was updated successfully, but these errors were encountered: