Comments (5)
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.
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.
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
andsince
not_in
andbut_in
before
andafter
or
andbetween
from edtf.js.
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.
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)
- License acquisition HOT 5
- Update to support latest spec HOT 3
- Inconsistent behavior for iterators on unspecified dates HOT 3
- February 29th on unspecified year HOT 2
- Year zero not treated as a leap year HOT 3
- Mismatches for XXXX-X2-<29+>
- -1XXX has incorrect min / max HOT 2
- Lists with continuations not parsing correctly HOT 2
- Usage in closed-source commercial product HOT 3
- Switch to ESM for good
- global is not defined HOT 10
- AssertionError when calling edtf("{1978,1988}") in prod HOT 13
- Day not considered unspecified in month-precision Level 0 date HOT 2
- JSON-schema validator HOT 9
- locale load can't be bundled anymore HOT 5
- allowing uaSymbol on undefined dates HOT 4
- minimal node example not loading HOT 11
- Invalid upper bound with dates before 1970-01-01 HOT 4
- Use unassert to remove assert in release builds HOT 6
- Parse error on trailing zeros HOT 9
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 edtf.js.