Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(utils): isAfterDate, isBeforeDate 추가 #652

Merged
merged 3 commits into from
Jan 2, 2025
Merged

feat(utils): isAfterDate, isBeforeDate 추가 #652

merged 3 commits into from
Jan 2, 2025

Conversation

ssi02014
Copy link
Contributor

@ssi02014 ssi02014 commented Jan 2, 2025

Overview

feat(utils): isAfterDate, isBeforeDate 추가

isAfterDate

without compareDate

  • 비교 날짜(compareDate)가 없을 때 현재 날짜를 기준으로 목표 날짜가 현재 날짜보다 이후인 경우 true를 반환합니다.
import { isAfterDate } from '@modern-kit/utils';

// 현재 날짜가 2025년 1월 1일 00:00:00 일 때
isAfterDate({ targetDate: new Date('2025-01-02') }); // true
isAfterDate({ targetDate: new Date('2024-12-31') }); // false

// 문자열 포맷도 허용합니다.
isAfterDate({ targetDate: '2025-01-02' }); // true

with compareDate

  • 비교 날짜(compareDate)가 있을 때 목표 날짜가 비교 날짜보다 이후인 경우 true를 반환합니다.
import { isAfterDate } from '@modern-kit/utils';

isAfterDate({ targetDate: new Date('2025-01-01'), compareDate: new Date('2024-12-31') }); // true
isAfterDate({ targetDate: new Date('2024-12-31'), compareDate: new Date('2025-01-01') }); // false

// 문자열 포맷도 허용합니다.
isAfterDate({ targetDate: '2025-01-02', compareDate: '2025-01-01' }); // true

inclusive option

  • inclusive 옵션이 true일 때 같은 날짜도 포함해서 비교합니다.
import { isAfterDate } from '@modern-kit/utils';

isAfterDate({
  targetDate: new Date('2025-01-01'),
  compareDate: new Date('2025-01-01'),
  inclusive: false,
});
// false

isAfterDate({
  targetDate: new Date('2025-01-01'),
  compareDate: new Date('2025-01-01'),
  inclusive: true,
});
// true

isBeforeDate

without compareDate

  • 비교 날짜(compareDate)가 없을 때 현재 날짜를 기준으로 목표 날짜가 현재 날짜보다 이전인 경우 true를 반환합니다.
import { isBeforeDate } from '@modern-kit/utils';

// 현재 날짜가 2025년 1월 1일 00:00:00 일 때
isBeforeDate({ targetDate: new Date('2024-12-31') }); // true
isBeforeDate({ targetDate: new Date('2025-01-02') }); // false

// 문자열 포맷도 허용합니다.
isBeforeDate({ targetDate: '2024-12-31' }); // true

with compareDate

  • 비교 날짜(compareDate)가 있을 때 목표 날짜가 비교 날짜보다 이전인 경우 true를 반환합니다.
import { isBeforeDate } from '@modern-kit/utils';

isBeforeDate({ targetDate: new Date('2024-12-31'), compareDate: new Date('2025-01-01') }); // true
isBeforeDate({ targetDate: new Date('2025-01-01'), compareDate: new Date('2024-12-31') }); // false

// 문자열 포맷도 허용합니다.
isBeforeDate({ targetDate: '2024-12-31', compareDate: '2025-01-01' }); // true

inclusive option

  • inclusive 옵션이 true일 때 같은 날짜도 포함해서 비교합니다.
import { isBeforeDate } from '@modern-kit/utils';

isBeforeDate({
  targetDate: new Date('2025-01-01'),
  compareDate: new Date('2025-01-01'),
  inclusive: false,
});
// false

isBeforeDate({
  targetDate: new Date('2025-01-01'),
  compareDate: new Date('2025-01-01'),
  inclusive: true,
});
// true

PR Checklist

  • All tests pass.
  • All type checks pass.
  • I have read the Contributing Guide document.
    Contributing Guide

Copy link

changeset-bot bot commented Jan 2, 2025

🦋 Changeset detected

Latest commit: 3fcaa26

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@modern-kit/utils Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@ssi02014 ssi02014 self-assigned this Jan 2, 2025
@ssi02014 ssi02014 added feature 새로운 기능 추가 @modern-kit/utils @modern-kit/utils labels Jan 2, 2025
Copy link

codecov bot commented Jan 2, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.24%. Comparing base (33cf068) to head (3fcaa26).
Report is 137 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #652      +/-   ##
==========================================
+ Coverage   97.41%   98.24%   +0.82%     
==========================================
  Files         164      177      +13     
  Lines        1470     1591     +121     
  Branches      361      419      +58     
==========================================
+ Hits         1432     1563     +131     
+ Misses         34       26       -8     
+ Partials        4        2       -2     
Components Coverage Δ
@modern-kit/react 96.95% <ø> (+1.73%) ⬆️
@modern-kit/utils 99.61% <ø> (-0.39%) ⬇️

@ssi02014 ssi02014 merged commit cd87aec into main Jan 2, 2025
3 checks passed
@ssi02014 ssi02014 deleted the feat/date branch January 2, 2025 14:45
@github-actions github-actions bot mentioned this pull request Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature 새로운 기능 추가 @modern-kit/utils @modern-kit/utils
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant