Skip to content

Commit

Permalink
Merge pull request #555 from gloddy-dev/hotfix/date-error
Browse files Browse the repository at this point in the history
Hotfix: 날짜 에러 해결
  • Loading branch information
guesung authored Jan 13, 2024
2 parents 237044d + 121c7ad commit c87cb47
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@ function validateDate(date: Date, time: TimeType, browser: string) {
const formatDateForm = browser === 'safari' ? 'yyyy/MM/dd' : 'yyyy-MM-dd';

const currentDate = new Date();
const meetDate = new Date(
format(date, formatDateForm) +
' ' +
(+time.fromHour + (time.fromAmPm === 'AM' ? 0 : 12)) +
':' +
time.fromMin
);
const meetDate = format(date, formatDateForm);
let meetHour = +time.fromHour + (time.fromAmPm === 'AM' ? 0 : 12);
if (meetHour === 24) meetHour = 0;
const meetMinute = +time.fromMin;

return currentDate < meetDate;
const meetDateObj = new Date(meetDate + ' ' + meetHour + ':' + meetMinute);
return currentDate < meetDateObj;
}

interface MainStepProps {
Expand Down
7 changes: 2 additions & 5 deletions src/hooks/useBrowser.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import { useDidMount } from './common/useDidMount';
import { getMobileDivce } from '@/utils/getMobileDevice';
import { useState } from 'react';

export default function useBrowser() {
const [browser, setBrowser] = useState('');
const mobileDevice = getMobileDivce();

useDidMount(() => {
const agent = navigator.userAgent;
if (agent.includes('Chrome')) setBrowser('chrome');
if (agent.includes('Safari') || mobileDevice === 'ios') setBrowser('safari');
if (navigator.userAgent.match(/Chrome/i) != null) setBrowser('chrome');
else if (navigator.userAgent.match(/ipad|iphone|Safari/i)) setBrowser('safari');
});

return browser;
Expand Down

0 comments on commit c87cb47

Please sign in to comment.