eachDays
See original GitHub issueReturn all dates in a interval of 2 dates. You can pass JSDates, strings SQL or DateTime instances.
eachDays(DateTime.local(2018, 11, 1), DateTime.local(2018, 11, 6))
eachDays(new Date(2018, 11, 1, 0, 0, 0), new Date(2018, 11, 6, 23, 59, 59))
eachDays('2018-11-01', '2018-11-06')
Returns
eachDays('2018-11-01', '2018-11-06', 'DateTime')
eachDays('2018-11-01', '2018-11-06', 'JSDate')
eachDays('2018-11-01', '2018-11-06', 'yyyy-MM-dd') // any custom format
https://gist.github.com/jonathanborges/092467191cef14bcc72a7214ed42c36f
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Eachday - ADHD Self-Management
Eachday provides you with the tools and evidence-based techniques you need to self-manage your ADHD with or without medication.
Read more >each day or each days ? - TextRanch
Rebetol capsules are to be administered orally each day in two divided doses (morning and evening) with food. Ribavirin capsules are to be...
Read more >Eachday (@eachday_ADHD) / Twitter
Eachday. @eachday_ADHD. Self-manage your ADHD with or without medication. Backed by. @carnegiemellon. VB 21' - Join our waitlist!
Read more >Eachday - Crunchbase Company Profile & Funding
Eachday provides tools and evidence-based techniques to self-manage ADHD. The company is based in Pittsburgh, Pennsylvania.
Read more >EachDay Health - IndieBio - #1 in Early Stage Biotech
“Eachday is a gamified digital therapeutic that reduces ADHD symptoms in adults and adolescents.” As of 2020, Adult ADHD impacted 9.34% of the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
There are a few reasons this function won’t go into Luxon:
My advice above to use iterate was wrong; we removed iterate a long time ago. But this works:
I have a project that heavily relies on date intervals written in PHP. I had to implement a custom
Interval
class that made an inclusive interval (startDate and endDate to be included) since the native one from PHP wasn’t properly working.So the final usage was something like this:
Behind the scenes, the
Interval::getIterator()
(which is called by PHP compiler) did the following:DatePeriod
class)DatePeriod
class), which is converted from iterator to arrayIt was all good and nice, until I found out that it won’t be that reliable compared to Chronos implementation. So I have in mind a rewrite of the component to use (ChronosInterval API)[https://api.cakephp.org/chronos/2.x/class-Cake.Chronos.ChronosInterval.html].
So, how my use case helps Luxon and JS world? Simply because JS (doesn’t have a simple iterator API)[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators] and it would pollute the code pretty much if you want to achieve that one directly in the library (which is, however, doable).
However, one could simply write a wrapper, like I did for another node.js project where I’m using this feature, that does what you need to be done. That wrapper simply does:
This function does the same thing that my
Interval
class does.This kind of coding style makes me to enforce library wrappers for my business logic and reuse that logic (e.g. make a provider function that gets the date time in a timezone depending on user’s choice
If there would be any problem in writing code this way, project devs would implement the method directly in
Interval
class.I mean, I don’t mind writing code this way, it feels more condensed and it makes me feel pretty safe that this is should an
Interval
class should behave, giving power tools.So yeah, libs can ease your life, but it shouldn’t do many things as it would break it, especially when implementation of some features are costlier that others.