Skip to content

How to compare POSIXTime to POSIXTimeRange? #69

Answered by juliusfrost
juliusfrost asked this question in Q&A
Discussion options

You must be logged in to vote

Okay I found that isinstance is implemented in the condition of if isinstance(data, Union) where data is a Union type
https://github.com/ImperatorLang/eopsin/blob/cee2aa9bb2910732f283ff9ac69e870a94024770/eopsin/type_inference.py#L222-L262

So I made an unoptimized implementation of the contains comparison:

def contains(time: POSIXTime, time_range: POSIXTimeRange) -> bool:
    # Lower bound
    lower_comparison = False
    lower_bound_limit = time_range.lower_bound.limit
    lower_bound_closed = time_range.lower_bound.closed
    if isinstance(lower_bound_limit, FinitePOSIXTime):
        lower_time = lower_bound_limit.time
        if isinstance(lower_bound_closed, TrueData):
            lowe…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@nielstron
Comment options

@nielstron
Comment options

@juliusfrost
Comment options

Answer selected by juliusfrost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants