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): getAge, isUnderAge 신규 함수 추가 #662

Merged
merged 2 commits into from
Jan 7, 2025
Merged

Conversation

ssi02014
Copy link
Contributor

@ssi02014 ssi02014 commented Jan 7, 2025

Overview

Issue: #661

getAge

주어진 생년월일을 기준으로 현재 나이를 계산합니다.

getAge(new Date('2006-01-01')); // 19

getAge('2006-01-01'); // 19

isUnderAge

주어진 생년월일을 기준으로 특정 나이보다 어린지 확인합니다.
inclusive 값을 기준으로 기준 나이를 포함할지 여부를 결정합니다.

without inclusive

import { isUnderAge } from '@modern-kit/utils';

// 현재 날짜 2025년 1월 1일 기준
isUnderAge({ birthDate: new Date('2006-01-02'), targetAge: 19 }); // true
isUnderAge({ birthDate: new Date('2006-01-01'), targetAge: 19 }); // false, 정확히 만 19세
isUnderAge({ birthDate: new Date('2005-12-31'), targetAge: 19 }); // false

isUnderAge({ birthDate: '2006-01-02', targetAge: 19 }); // true
isUnderAge({ birthDate: '2006-01-01', targetAge: 19 }); // false, 정확히 만 19세
isUnderAge({ birthDate: '2005-12-31', targetAge: 19 }); // false

with inclusive

  • inclusive 값을 기준으로 기준 나이를 포함할지 여부를 결정합니다. (기본값: false)
  • inclusive 값이 true일 경우, 기준 나이를 포함하며, false일 경우, 기준 나이를 포함하지 않습니다.
// 2025년 01월 01일 기준
// inclusive 값을 기준으로 기준 나이를 포함할지 여부를 결정합니다.
isUnderAge({ birthDate: '2006-01-01', targetAge: 19, inclusive: true }); // true
isUnderAge({ birthDate: '2006-01-01', targetAge: 19, inclusive: false }); // false

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 7, 2025

🦋 Changeset detected

Latest commit: b1cb847

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

Copy link

codecov bot commented Jan 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.22%. Comparing base (33cf068) to head (b1cb847).
Report is 142 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #662      +/-   ##
==========================================
+ Coverage   97.41%   98.22%   +0.81%     
==========================================
  Files         164      180      +16     
  Lines        1470     1634     +164     
  Branches      361      438      +77     
==========================================
+ Hits         1432     1605     +173     
+ Misses         34       27       -7     
+ Partials        4        2       -2     
Components Coverage Δ
@modern-kit/react 96.95% <ø> (+1.73%) ⬆️
@modern-kit/utils 99.50% <ø> (-0.50%) ⬇️

@ssi02014 ssi02014 changed the title Feat/date feat(utils): getAge, isUnderAge 신규 함수 추가 Jan 7, 2025
@ssi02014 ssi02014 self-assigned this Jan 7, 2025
@ssi02014 ssi02014 added feature 새로운 기능 추가 @modern-kit/utils @modern-kit/utils labels Jan 7, 2025
@ssi02014 ssi02014 merged commit c62d822 into main Jan 7, 2025
3 checks passed
@ssi02014 ssi02014 deleted the feat/date branch January 7, 2025 09:13
@github-actions github-actions bot mentioned this pull request Jan 7, 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