Skip to content

Commit adc69ea

Browse files
committed
refactor: Use LayerStack endOfInterval() instead of internal
1 parent 700f976 commit adc69ea

3 files changed

Lines changed: 5 additions & 17 deletions

File tree

packages/layerchart/src/lib/components/MonthPath.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131

3232
<script lang="ts">
3333
import { timeWeek, timeMonth, timeYear } from 'd3-time';
34-
import { endOfInterval } from '$lib/utils/date.js';
3534
import { cls } from '@layerstack/tailwind';
35+
import { endOfInterval } from '@layerstack/utils';
3636
import { layerClass } from '$lib/utils/attributes.js';
3737
import Spline, { type SplinePropsWithoutHTML } from './Spline.svelte';
3838
@@ -58,7 +58,7 @@
5858
const startWeek = $derived(timeWeek.count(timeYear(date), date));
5959
6060
// end of month
61-
const monthEnd = $derived(endOfInterval(date, timeMonth));
61+
const monthEnd = $derived(endOfInterval('month', date));
6262
const endDayOfWeek = $derived(monthEnd.getDay());
6363
const endWeek = $derived(timeWeek.count(timeYear(monthEnd), monthEnd));
6464

packages/layerchart/src/lib/utils/date.ts

Lines changed: 0 additions & 12 deletions
This file was deleted.

packages/layerchart/src/routes/docs/components/Calendar/+page.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
import Preview from '$lib/docs/Preview.svelte';
99
import { createDateSeries } from '$lib/utils/genData.js';
1010
import { shared } from '../../shared.svelte.js';
11-
import { endOfInterval } from '$lib/utils/date.js';
11+
import { endOfInterval } from '@layerstack/utils';
1212
1313
const now = new Date();
1414
const firstDayOfYear = timeYear.floor(now);
15-
const lastDayOfYear = endOfInterval(now, timeYear);
15+
const lastDayOfYear = endOfInterval('year', now);
1616
1717
const data = createDateSeries({ count: 365 * 4, min: 10, max: 100, value: 'integer' }).map(
1818
(d) => {
@@ -147,7 +147,7 @@
147147
<Layer type={shared.renderContext}>
148148
{#each range(2019, 2024) as year, i}
149149
{@const start = new Date(year, 0, 1)}
150-
{@const end = endOfInterval(start, timeYear)}
150+
{@const end = endOfInterval('year', start)}
151151
<Group y={140 * i}>
152152
<Text
153153
value={year}

0 commit comments

Comments
 (0)