Comments (6)
As moving between DateTime
and ZonedDateTime
isn't lossless there definitely needs to be some user input to make this transition. Could you provide more context into why you want this operation? I suspect this may influence some design in TimeZones.jl more than Intervals.jl
from intervals.jl.
Our use case is that we need to work around JuliaTime/TimeZones.jl#271. Since we have large arrays of timestamp intervals with the same timezone we can just determine that timezone by sampling the file. Only parsing the datetime component is faster and more space efficient. To avoid breaking internally APIs we add the timezone back, only when queried.
from intervals.jl.
Our use case is that we need to work around JuliaTime/TimeZones.jl#271
It would be great to find a path forward on that. As you're already working with switching to using DateTime
why don't you make:
struct UTCDateTime <: AbstractZonedDateTime
utc::DateTime
end
This avoids having to implicitly keep track of the DateTime
time zone and avoids the isbits problem. The main challenges here is we'd need to define AbstractZonedDateTime
and your internal APIs would also need to support this.
Finally, even with UTCDateTime
the convert
interface leaves something to be desired. I think this is another good example for JuliaTime/TimeZones.jl#318 and could eventually be done with:
convert(AnchoredInterval{ZonedDateTime{TZ"America/New_York"}}, interval::AnchoredInterval{UTCDateTime})
convert(AnchoredInterval{UTCDateTime}, interval::AnchoredInterval{ZonedDateTime})
from intervals.jl.
The main challenges here is we'd need to define AbstractZonedDateTime and your internal APIs would also need to support this.
Yeah, that's the main reason why I didn't want to get into it. In this particular case, we don't really need a more general solution, and even the UTCDateTime solution would require more significant updates. I agree that in the future we'll probably want to go that direction, but for the couple hundred LOC in which we're tracking the timezone I don't think it's a priority.
FWIW, I think these conversions should be supported regardless of whether the isbits
issue is fixed. We already support astimezone
here anyways.
from intervals.jl.
Yeah, that's the main reason why I didn't want to get into it.
Fair enough. It helps seeing the bigger picture to figure out a better path forward.
FWIW, I think these conversions should be supported regardless of whether the
isbits
issue is fixed. We already supportastimezone
here anyways.
The astimezone
methods here have always felt out of place but I can't dispute they are convenient with the current interface. The proposed _to_zdt
seems even more out of place and maybe should live near these couple hundred LOC for now. Just my opinion though.
from intervals.jl.
The proposed _to_zdt seems even more out of place and maybe should live near these couple hundred LOC for now.
Yeah, that's what we're doing for now, just opened this issue more for reference. If we want to drop the astimezone
stuff, then I think it's fine to close this issue. It would be nice if there was a convert interface that allowed you to generically convert the elements. Kind of like how parse takes an element_parser
.
from intervals.jl.
Related Issues (20)
- Constructor of Interval inherently type unstable? HOT 1
- Multirange type HOT 1
- CI failure: display tests fail on julia v1.7
- Transitive dependencies on TimeZones.jl HOT 1
- How do I make an unbounded interval? HOT 1
- TagBot trigger issue HOT 6
- Phase out `intersect(::AbstractInterval, ::AbstractInterval) -> AbstractInterval` HOT 1
- Unconventional definitions of inequality
- StepRangeLen broken for AnchoredIntervals on Julia 1.8
- stackoverflow from recursive call in `find_intersections`
- `union` example in doc is wrong
- Storing open-ness as a type parameter makes Postgres parsing type unstable HOT 4
- bug in `intersect` HOT 3
- Drop all hardcoded reference to ZonedDateTime
- Link not formatted properly in documentation
- Reconsider explict bounds parameters for anchored intervals
- Use Infinity.jl for representing Bounded vs Unbounded intervals HOT 1
- 0.0 <= Interval{Float64, Closed, Closed}(0.0, 1.0) returns false HOT 1
- Iterator interface on IntervalSet HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from intervals.jl.