@@ -2,16 +2,17 @@ import { useMemo } from "react";
22import { useCalendarContext } from "./contexts/calendar.js" ;
33import { useDayContext } from "./contexts/day.js" ;
44import { useViewContext } from "./contexts/view.js" ;
5- import { dayjs } from "./extended-dayjs .js" ;
5+ import { getToday } from "./helpers .js" ;
66
7- export function useView ( ) {
7+ export function useViewState ( ) {
88 const viewContext = useViewContext ( ) ;
99 return viewContext . viewState ;
10- // const [view, setView] = context.viewState;
11- // const viewWithOffset = view.add(viewContext.viewOffset, "month");
12- // return [viewWithOffset, setView] as const;
1310}
1411
12+ export function useCalendarView ( ) {
13+ const context = useViewContext ( ) ;
14+ return context ;
15+ }
1516export function useCalendarValue ( ) {
1617 const context = useCalendarContext ( ) ;
1718 return context . valueState ;
@@ -76,13 +77,7 @@ export function useTodaysDate() {
7677 const timezone = useCalendarTimezone ( ) ;
7778
7879 return useMemo ( ( ) => {
79- if ( timezone === null ) {
80- return dayjs ( ) ;
81- }
82- if ( timezone === "UTC" ) {
83- return dayjs ( ) . utc ( ) ;
84- }
85- return dayjs ( ) . tz ( timezone ) ;
80+ return getToday ( timezone ) ;
8681 } , [ timezone ] ) ;
8782}
8883
@@ -97,7 +92,7 @@ export function useIsToday() {
9792
9893export function useIsNeighboringMonth ( ) {
9994 const { day } = useDayContext ( ) ;
100- const [ view ] = useView ( ) ;
95+ const [ view ] = useViewState ( ) ;
10196
10297 return useMemo ( ( ) => {
10398 return ! day . isSame ( view , "month" ) ;
0 commit comments