Coder Social home page Coder Social logo

Comments (5)

inukshuk avatar inukshuk commented on May 26, 2024 1

Here are some interesting notes by Dijkstra on a similar topic. In order to keep the API concise I would suggest to keep between as it is (and, like you say, make it work irrespective of temporal order); rename until to through and have until return a half-open interval by (with inclusive lower bound); this way, until would be the method that is most useful by Dijkstra's reasoning.

If we can think of a good name, we could add a method for the other half-open interval. @abbymullen can you think of a verb that would make sense here? That is, "June something August", which would imply the months July to August (without June)?

If there is no suitable name, I'd just not add that variant to the API, and you can still do [...edtf('2016-06').next().through('2016-08')].

from edtf.js.

inukshuk avatar inukshuk commented on May 26, 2024

I absolutely agree that such methods would be useful and I'd be happy to implement them, but I would appreciate help in specifying the exact semantics. The names between and until were not picked after long deliberation so I'd be open to changing them, if necessary, for a more consistently named API.

from edtf.js.

Crissov avatar Crissov commented on May 26, 2024

Like I said, I’m not the best person to help there. I think between is fine as it is and it should give the same result regardless of the temporal sequence of the dates provided. It may make more sense to use through for the semantics that until currently has.

I’m not sure which of these would really be needed. Anyhow, here’s something.

[...edtf('2016-05').⟨name⟩('2016-07')]

2016-05  2016-06 2016-07 English
not_in dates in May that are not in July
before dates in May that are before July
between dates between May and July (~ neither_in / nor_in)
but_in dates that are not in May but in July
by, until by, until dates from [the start of] May by/until [before the start of] July
? ? dates from [after the end of] May to [the end of] July
or or dates either in May or July [or both], i.e. merge/combine/add
through, to through, to through, to dates from [the start of] May through/[un/up]to [the end of] July

[...edtf('2016-07').⟨name⟩('2016-05')]

2016-05  2016-06 2016-07 English
not_in dates in July that are not in May
but_in dates that are not in July but in May
between dates between July and May (exclusive)
after dates in July that are after May
? ? dates to [before the start of] July since [the start of] May
by, since by, since dates to [the start of] July by/since [after the end of] May
or or dates either in July or May [or both]
through, from through, from through, from dates to [the start of] May through/from [the end of] July

[...edtf('2016-05/06').⟨name⟩('2016-06/07')]

2016-05  2016-06 2016-07 English
not_in dates in May/June that are not in June/July
before dates in May/June that are before June/July
dates between May/June and June/July (~ neither_in / nor_in)
but_in dates that are not in May/June but in June/July
by, until dates from [the start of] May/June by/until [before the start of] June/July
? dates from [after the end of] May/June to [the end of] June/July
or or or dates in May/June or June/July or both
xor xor dates either in May/June or June/July
through, to through, to through, to dates from [the start of] May/June through/[un/up]to [the end of] June/July

[...edtf('2016-06/07').⟨name⟩('2016-05/06')]

Composite pairs

  • from and since
  • not_in and but_in
  • before and after
  • or and between

from edtf.js.

inukshuk avatar inukshuk commented on May 26, 2024

OK added between, until and through as described above. All of the methods work in reverse order too, which is not intuitive given the names until and through as pointed out earlier, but I am inclined to to see that as a feature. We could add aliases which make more sense linguistically for reverse order specifically (i.e., edtf('2016').backUntil('2010')), but that might be overdoing it.

from edtf.js.

inukshuk avatar inukshuk commented on May 26, 2024

Actually, one cool detail about the reverse order is that it gives you the missing variant in reverse, e.g.: [...edtf('2016-08').until('2016-06')].reverse().

from edtf.js.

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.