패키지, 저장소 및 앱 카테고리 검색

패키지 상세v1.0.0

age_calculator

누군가의 나이를 일, 달, 년 단위로 계산하는 Flutter 패키지이며, 두 날짜 간의 차이를 찾는 데에도 사용할 수 있습니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
1.3만
좋아요
66
Pub 점수
160

패키지 설치

flutter pub add age_calculator

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

age_calculator 패키지는 사람의 나이를 연, 월, 일 단위로 계산하기 위해 설계된 플러터 유틸리티입니다. 또한 두 날짜 간의 정확한 차이를 계산할 수 있도록 해줍니다. 건강 앱, 등록 양식, 이벤트 기획 도구와 같이 나이 검증이나 날짜 비교가 필요한 애플리케이션에 적합합니다. 이 패키지는 Android, iOS, Web, macOS, Windows, Linux 등 모든 주요 플랫폼을 지원하여 크로스플랫폼 일관성을 보장합니다. 개발자가 앱에 나이 계산 기능을 쉽게 통합할 수 있도록 간단하고 직관적인 API를 제공합니다.

사용 사례

  • 사용자 등록 시 나이 검증
  • 의료 앱에서 환자 나이 계산하기
  • 나이에 따라 이벤트 참가 자격 결정
  • 스케줄링 목적의 날짜 비교
  • 날짜 차이를 사용하여 마일스톤 추적하기

주요 기능

  • 연령(년, 월, 일 단위)을 계산합니다
  • 날짜 차이를 정확하게 계산합니다
  • 크로스 플랫폼 호환성
  • 간단하고 직관적인 API
  • 널 안전한 날짜 입력을 지원

적합한 대상

  • 나이 확인이 필요한 폼 검증
  • 건강 및 웰빙 애플리케이션
  • 생일 및 기념일 트래커
  • 시간 기반 학습을 갖춘 교육 앱
  • 정확한 날짜 산술이 필요한 응용 프로그램

고려 사항

  • 유효한 DateTime 입력이 필요합니다
  • 윤년과 같은 에지 케이스 처리가 필요할 수 있습니다
  • 매우 큰 날짜 범위에 최적화되지 않음
  • 날짜 기반 계산에만 제한됨
  • 시간대 인식 기능을 포함하지 않음

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

age_calculator

A Flutter package that allows you to perform operations between dates:

  • Calculate a person's age and the time remaining to their next birthday in years, months and days.
  • Calculate differences between two dates in years, months and days.
  • Add years, months and days to any date.

Getting Started

In your flutter project add the dependency:

dependencies: ... age_calculator: ^1.0.0

For help getting started with Flutter, view the online documentation.

Example
import 'package:age_calculator/age_calculator.dart';

void main() {
  DateTime birthday = DateTime(1997, 3, 5);

  DateDuration duration;

  // Find out your age as of today's date 2021-03-08
  duration = AgeCalculator.age(birthday);
  print('Your age is $duration'); // Your age is Years: 24, Months: 0, Days: 3

  //Find out your age on any given date
  duration = AgeCalculator.age(birthday, today: DateTime(2030, 5, 1));
  print('Your age is $duration'); // Your age is Years: 33, Months: 1, Days: 26

  // Find out when your next birthday will be at 2021-03-08
  duration = AgeCalculator.timeToNextBirthday(birthday);
  print('You next birthday will be in $duration');
  // You next birthday will be in Years: 0, Months: 11, Days: 25

  // Find out when your next birthday will be on any given date
  duration = AgeCalculator.timeToNextBirthday(birthday,
      fromDate: DateTime(2021, 3, 2));
  print('You next birthday will be in $duration');
  // You next birthday will be in Years: 0, Months: 0, Days: 3

  // Find out the difference between two dates
  duration = AgeCalculator.dateDifference(
    fromDate: DateTime(2021, 1, 2),
    toDate: DateTime(2025, 5, 2),
  );
  print('The difference is $duration');
  // You next birthday will be in Years: 4, Months: 4, Days: 0

  // Add time to any date
  DateTime date = AgeCalculator.add(
      date: DateTime(2021, 1, 2),
      duration: DateDuration(years: 5, months: 2, days: 1));
  print(date);
  // 2026-03-03 00:00:00.000
}

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트