-
-
Notifications
You must be signed in to change notification settings - Fork 67
Add crate for integration with the AWS SDK for Rust #260
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
Conversation
8c795d0
to
8a8cdbc
Compare
Wouldn't this be better in aws_smithy_types_convert like the |
I created a PR for that previously, but they didn't want to add it since jiff isn't stable yet. |
Ref smithy-lang/smithy-rs#3826 I'll get to reviewing this soon, after I get through the batch of changes related to core-only work. |
No, worries.... it is just some simple convenience helpers, so it is not like my code is dependent on this :) |
a49bdba
to
e1a5e77
Compare
The nanosecond portion of a jiff Timestamp are negative for times before the Unix epoch (it ranges between +1s and -1s), this should be taken into account (e.g. the type casts between u32 and i32 are incorrect). |
The smithy datetime is defined as seconds and nano seconds since unix epoch, so a simple check for that should fix this. I will have a look at it later. |
@fiadliel Ok, it seems that I was wrong about DateTime being only positive. But I have added nano second conversions for times before epoc. Please have a look and see if it looks correct to you. I checked for conversion the other way also, but that seems to be handled by jiff automatically. |
Added some tests and ensured the calculations are correct for negative epoch |
I think that fixes the calculation around times before 1970. Thanks! One last thing: I think you should reconsider being able to convert |
I don't really have any strong opinions about including Zoned or not. But I added it since this is to make things a bit more convenient, not having to jump through a Timestamp first. And it is clearly documented that it creates a Zoned for timezone UTC, so I don't really see any issues with having it included. |
@BurntSushi have you had time to look at this? |
Thanks for the ping. In terms of whether I'm willing to bring this crate on and maintain it indefinitely, I'm somewhat unsure. It does look pretty lightweight. On the other hand, the smithy-lang people seem on board with supporting Jiff once it's 1.0, and that shouldn't be too far away. The other consideration here is the complexity of the actual conversion. For How would you use a crate like this? Is this something where you could define a helper function on your own and just use that? I also don't have a good sense of how many people would actually benefit from this, which makes it hard to determine if this is worth maintaining indefinitely on my end. Separately from the question of whether we should do this, the actual change here would need some work. Specifically:
|
Fair points! I'll wait for 1.0 and try to add it to the smithy-lang crate And about usage, sure this could easily be a helper function you define by your self. However, it is always convenient to get something that is tested, especially when there are non-obvious cases like before epoch where you have to recalculate things a little bit. |
Another point of clarity here is that I'm definitely not trying to be a receptacle of Jiff integrations with other crates. I did SQLx and Diesel because I perceived folks were bouncing off of the lack of Jiff integration for those specific crates and because they were unwilling to add upstream support, and I did
All righty, thanks. I'll close this out then. If this doesn't end up working, please feel free to swing back around here and we can re-evaluate. And I do acknowledge that having a tested conversion routine is beneficial. For me, it's more about whether there's enough people hitting this that it's worth me maintaining in order to overcome what I hope is a short-term gap. If, once Jiff is 1.0 and the smithy folks still won't add support for it (and it seems like they would, or at least, that's I think what they telegraphed), then I'd be more open to supporting this longer term. |
I have implemented some basic conversion from the AWS Smithy type
DateTime
into/fromTimestamp
andZoned
.