Skip to content

Commit

Permalink
use isSameTZDay for current day highlights
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSonOfThomp committed Dec 4, 2023
1 parent f6a7320 commit d7af825
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
getFullMonthLabel,
getISODate,
getUTCDateString,
isSameTZDay,
isSameUTCDay,
isSameUTCMonth,
} from '../../shared/utils';
Expand All @@ -38,7 +39,7 @@ import { DatePickerMenuHeader } from './DatePickerMenuHeader';

export const DatePickerMenu = forwardRef<HTMLDivElement, DatePickerMenuProps>(
({ onKeyDown, ...rest }: DatePickerMenuProps, fwdRef) => {
const { isInRange, isOpen, setIsDirty } = useDatePickerContext();
const { isInRange, isOpen, setIsDirty, timeZone } = useDatePickerContext();
const {
refs,
today,
Expand Down Expand Up @@ -216,6 +217,8 @@ export const DatePickerMenu = forwardRef<HTMLDivElement, DatePickerMenuProps>(
}
};

console.log({ today, iso: getISODate(today), timeZone });

Check failure on line 220 in packages/date-picker/src/DatePicker/DatePickerMenu/DatePickerMenu.tsx

View workflow job for this annotation

GitHub Actions / Check lints

Unexpected console statement

return (
<MenuWrapper
ref={ref}
Expand All @@ -225,6 +228,7 @@ export const DatePickerMenu = forwardRef<HTMLDivElement, DatePickerMenuProps>(
className={menuWrapperStyles}
usePortal
onKeyDown={handleMenuKeyPress}
data-today={today.toISOString()}
{...rest}
>
<div className={menuContentStyles}>
Expand All @@ -247,7 +251,7 @@ export const DatePickerMenu = forwardRef<HTMLDivElement, DatePickerMenuProps>(
ref={cellRefs(getISODate(day))}
aria-label={getUTCDateString(day)}
isHighlighted={isSameUTCDay(day, highlight)}
isCurrent={isSameUTCDay(day, today)}
isCurrent={isSameTZDay(today, day, timeZone)}
state={getCellState(day)}
onClick={cellClickHandlerForDay(day)}
data-iso={getISODate(day)}
Expand Down
2 changes: 1 addition & 1 deletion packages/date-picker/src/shared/utils/isSameTZDay/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { isSameUTCDay } from '../isSameUTCDay';
* ```
*
* @param zoned A Date object presumed to be in `timeZone`
* @param utc A UTC Date objects
* @param utc A UTC Date object
* @param timeZone An IANA timeZone string
*/
export const isSameTZDay = (
Expand Down

0 comments on commit d7af825

Please sign in to comment.