Skip to content

Commit

Permalink
fix range
Browse files Browse the repository at this point in the history
  • Loading branch information
Liam-Tait committed Jul 23, 2024
1 parent 103ab99 commit 7fd08d4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
8 changes: 3 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/eachDateInRange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function* eachDateInRange(
end: number,
): Generator<number> {
let current = start;
while (current < end) {
while (current <= end) {
yield current;
current = nextDay(current);
}
Expand Down
3 changes: 2 additions & 1 deletion test/eachDateInRange.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe("eachDateInRange", () => {
const start = fromYMD(2025, 1, 1);
const end = fromYMD(2025, 2, 1);
const result = Array.from(eachDateInRange(start, end));
assert.strictEqual(result.length, 31); // 31 days in January
assert.strictEqual(result.length, 32); // 31 days in January + 1 day in February
assert.deepStrictEqual(result.map(toISOString), [
"2025-01-01",
"2025-01-02",
Expand Down Expand Up @@ -42,6 +42,7 @@ describe("eachDateInRange", () => {
"2025-01-29",
"2025-01-30",
"2025-01-31",
"2025-02-01",
]);
});
test("generates no dates if start is equal to end", () => {
Expand Down

0 comments on commit 7fd08d4

Please sign in to comment.