feat: Relax UnixTime construction from String#19
Conversation
|
It would be nice that we get a version bump after this merge |
|
Thanks, happy to merge this change in! If you could remove the format and style changes first, that would be good. I prefer expression style to explicit return statements. You can bump the version in the Project.toml, and I'll register it after merge. |
14b0c20 to
d92da37
Compare
|
Thank you @ancapdev , I have splitted the PR with a format commit and added a version bump. |
d92da37 to
948ffe4
Compare
|
Oh sorry, I read your formatting message wrong:) I removed the formatting at all and included your suggesttion for DATEFORMAT |
No worries, I've merged it, will release it soon |
|
Is the promotion rule intentional? |
Good point, I glanced over and missed that. It's probably a bit unsafe, since it loses range on DateTime. Thoughts? |
|
I don't have an opinion on whether this should go in or not, your call. The only comment is that I believe the promotion rule shouldn't be necessary for this specific feature. If a conversion was needed, it could just as well be done explicitly. It was probably added for the last testcase, named "comparison with DateTime". |
|
@Beforerr what was your rationale with that? |
|
Oh I just think this is a useful feature as without this promotion we can not directly compare DateTime with UnixTime (as they are both AbstractDateTime, and UnixTime has better precision so promoting DateTime to UnixTime is a fair operation?). Is this causing any bugs on your side @thirtysixbananas ? |
|
Without it many functions like |
|
The issue I see with the promote rule is you can have NanoDate.jl for example implements comparisons directly: https://github.com/JuliaTime/NanoDates.jl/blob/main/src/compare.jl. I wrote UnixTimes.jl because I wanted something that was more efficient, limited to 64 bits of nanoseconds since epoch, it serves a lot of practical use cases (financial data, logging, telemetry, sensors, etc), but it's quite incomplete as far as features like this. |
|
I understand. Yes it would be nice to have direct comparison. On the other hand, this promotion is quite similar to what |
|
NanoDates also has |
Looks like a bug, no? |
|
Indeed like a bug (I felt like this kinda of overflow/underflow things are quite common though :< |
It does yes, but NanoDate contains all the range and precision of types it promotes from, so that's safe. From the manual
That said, I think we can leave this in for now and refine it later. I think it's unlikely that anyone is using |
Together with the ability to compare UnixTime with DateTime
Close #18
P.S.: There is some autoformatting from Runic.jl, I can remove if not wanted