Giter Site home page Giter Site logo

Comments (5)

omus avatar omus commented on May 24, 2024 1

I like that proposal. My only issue is that I think AbstractAnchoredInterval will be used allot and it a little long.

from intervals.jl.

spurll avatar spurll commented on May 24, 2024

My plan is to proceed with solution 1 for now, and consider 2 in the future.

from intervals.jl.

omus avatar omus commented on May 24, 2024

This means that HourEnding{DateTime}(now()) will not be rounded (as it's just an alias for AnchoredInterval{Hour(-1), DateTime}), which may lead to confusion

One way to support HourEnding{DateTime}(now()) to be rounded while having AnchoredInterval{Hour(-1), DateTime}) not be rounded while still using type aliases would be to introduce an additional type parameter.

MWE:

using Base.Dates
using Base.Dates: TimeType
const AbstractDateTime = TimeType

struct AnchoredInterval{P, T, R}
    anchor::T
end

AnchoredInterval{P, T}(i::T) where {P, T} = AnchoredInterval{P, T, false}(i)

const HourEnding{T} = AnchoredInterval{Hour(-1), T, true} where T <: AbstractDateTime
HourEnding{T}(i::T) where T <: AbstractDateTime = invoke(HourEnding{T}, Tuple{Any}, ceil(i, Hour))

HourEnding{DateTime}(now())
AnchoredInterval{Hour(-1), DateTime}(now())

from intervals.jl.

omus avatar omus commented on May 24, 2024

I think I would prefer option 2 however.

from intervals.jl.

spurll avatar spurll commented on May 24, 2024

It seems to me that the third type parameter is likely to cause a lot of confusion.

How do you feel about something like:

AbstractInterval{T} (abstract)
↳ Interval{T} (concrete)
↳ AbstractAnchoredInterval{P, T} (abstract)
  ↳ AnchoredInterval{P, T} (concrete)
  ↳ RoundedAnchoredInterval{P, T} (concrete)
    ↳ HourEnding{T} (type alias for RoundedAnchoredInterval{Hour(-1), T})
    ↳ HourBeginning{T} (type alias for RoundedAnchoredInterval{Hour(1), T})

Names subject to change, of course.

from intervals.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.