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

패키지 상세v1.5.3

dart_date

날짜 조작 라이브러리. DateTime 확장. 또한 Interval 개체도 포함되어 있습니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
4.3만
좋아요
189
Pub 점수
150

패키지 설치

flutter pub add dart_date

패키지 개요

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

일반적인 DateTime 확장을 통해 날짜 및 시간 조작을 단순화하는 Dart 패키지입니다. 시간 단위의 추가 또는 감소, 날짜 비교, 포맷팅과 같은 일반적인 작업을 위한 깔끔한 API를 제공합니다. 스케줄링이나 지속 시간 계산에 유용한 시간 범위를 나타내는 Interval 클래스도 포함되어 있습니다. 플러터 및 Dart 애플리케이션에서 다양한 플랫폼에서 날짜 처리를 위한 가볍고 사용하기 쉬운 솔루션을 찾는 개발자를 위해 설계되었습니다.

사용 사례

  • 날짜 산술 처리
  • DateTime 인스턴스 비교
  • UI에서 날짜 형식 지정
  • 시간 간격 관리
  • 작업 예약
  • 날짜 문자열 파싱 및 검증

주요 기능

  • DateTime 확장 메서드
  • 시간 범위용 간격 클래스
  • 크로스 플랫폼 호환성
  • 간단하고 읽기 쉬운 API
  • 외부 종속성 없음
  • 모든 주요 플랫폼을 지원합니다

적합한 대상

  • 날짜 논리를 필요로 하는 Flutter 앱
  • 백엔드 서비스의 타임스탬프 처리
  • 캘린더 또는 일정 기능을 갖춘 앱
  • 최소한의 설정을 원하는 개발자
  • 일관된 날짜 처리가 필요한 프로젝트

고려 사항

  • 기본적인 날짜 연산에 국한됨
  • 로컬라이제이션 지원 없음
  • 복잡한 시간대 처리에 적합하지 않음
  • 다양한 형식에서의 분석을 포함하지 않음
  • 시간대를 수동으로 처리해야 합니다
  • 내장된 검증 유틸리티 없음

원본 README

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

dart_date

Dart Extensions for DateTime

dart_date provides the most comprehensive, yet simple and consistent toolset for manipulating Dart dates.

Inspired by date-fns

Usage

  • Use instance.method() for added methods.
  • Use instance.property for added getter properties.
  • Use Date.method() for added static methods.
  • Use Date.property for added static getter properties.
DE (String): Heute ist 18-Juni-2020
DE (Date): 2020-06-18 00:00:00.000
ES (Timeago): hace 3 meses
EN (Format): June 18 2020, 8:33:52 AM
.UTC: 2006-06-06 11:06:06.006006Z
Closest to now (2020-06-18 08:33:52.683698): 2020-06-16 08:33:52.610450 (2 days ago)
true
Human String: Thu Nov 20 2014 16:51:30
Yesterday: 2020-06-17 08:33:52.700225
Tomorrow: 2020-06-19 08:33:52.700579
  const pattern = '\'Heute ist\' dd-MMMM-yyyy';
  final n = DateTime.now();
  final de_String = DateTime.now().format(pattern, 'de_DE');
  final de_Date = Date.parse(de_String, pattern: pattern, locale: 'de_DE');
  print(
    'DE (String): $de_String',
  );
  print(
    'DE (Date): $de_Date',
  );

  final es_Timeago = DateTime.now().subDays(100).timeago(locale: 'es');
  print("ES (Timeago): $es_Timeago");

  final en_Format = DateTime.now().format('MMMM dd y, h:mm:ss a');
  print("EN (Format): $en_Format");

  final utc = DateTime(2006, 6, 6, 6, 6, 6, 6, 6).UTC;
  print(".UTC: $utc");

  var now = DateTime.now();
  var closest = now.closestTo(
    [
      n.nextWeek,
      n.previousDay.previousDay,
      n.previousWeek.nextDay,
      n.nextMonth,
      n.nextYear,
    ],
  );
  print('Closest to now ($now): $closest (${closest.timeago()})');

  print(Date.today is DateTime);

  print("Human String: " +
      DateTime.parse('2014-11-20T16:51:30.000Z').toHumanString());

  print("Yesterday: " + (Date.today - Duration(days: 1)).toString());
  print("Tomorrow: " + (Date.today + Duration(days: 1)).toString());

LICENSE

MIT

API

Check full docs

Date extension on DateTime

Properties
clone → DateTime
endOfDay → DateTime
endOfHour → DateTime
endOfISOWeek → DateTime
endOfMinute → DateTime
endOfMonth → DateTime
endOfSecond → DateTime
endOfWeek → DateTime
endOfYear → DateTime
getDate → int
getDay → int
getDayOfYear → int
getDaysInMonth → int
getDaysInYear → int
getHours → int
getMicroseconds → int
getMicrosecondsSinceEpoch → int
getMilliseconds → int
getMillisecondsSinceEpoch → int
getMinutes → int
getMonth → int
getSeconds → int
getTime → int
getTimeZoneName → String
getTimeZoneOffset → Duration
getWeekday → int
getYear → int
getWeekYear → int
getWeek → int
getISOWeek → int
getISOWeeksInYear → int
isFirstDayOfMonth → bool
isFriday → bool
isFuture → bool
isLastDayOfMonth → bool
isLeapYear → bool
isMonday → bool
isPast → bool
isSaturday → bool
isSunday → bool
isThisHour → bool
isThisMinute → bool
isThisMonth → bool
isThisSecond → bool
isThisYear → bool
isThursday → bool
isToday → bool
isTomorrow → bool
isTuesday → bool
isUTC → bool
isWednesday → bool
isWeekend → bool
isYesterday → bool
local → DateTime
nextDay → DateTime
nextMonth → DateTime
nextWeek → DateTime
nextYear → DateTime
previousDay → DateTime
previousMonth → DateTime
previousWeek → DateTime
previousYear → DateTime
secondsSinceEpoch → int
startOfDay → DateTime
startOfHour → DateTime
startOfISOWeek → DateTime
startOfMinute → DateTime
startOfMonth → DateTime
startOfSecond → DateTime
startOfWeek → DateTime
startOfYear → DateTime
startOfWeekYear → DateTime
startOfISOWeekYear → DateTime
timestamp → int
toLocalTime → DateTime
toUTC → DateTime
utc → DateTime
Methods
addDays(int amount) → DateTime
addHours(int amount) → DateTime
addMicroseconds(int amount) → DateTime
addMilliseconds(int amount) → DateTime
addMinutes(int amount) → DateTime
addMonths(int amount) → DateTime
addQuarters(int amount) → DateTime
addSeconds(int amount) → DateTime
addWeeks(int amount) → DateTime
addYears(int amount) → DateTime
closestIndexTo(Iterable<DateTime> datesArray) → int
closestTo(Iterable<DateTime> datesArray) → DateTime
compare(DateTime other) → int
diff(DateTime other) → Duration
differenceInDays(DateTime other) → int
differenceInHours(DateTime other) → int
differenceInMicroseconds(DateTime other) → int
differenceInMilliseconds(DateTime other) → int
differenceInMinutes(DateTime other) → int
differenceInSeconds(DateTime other) → int
eachDay(DateTime date) → Iterable<DateTime>
equals(DateTime other) → bool
format(String pattern, [String locale = 'en_US']) → String
isEqual(dynamic other) → bool
isSameDay(DateTime other) → bool
isSameHour(DateTime other) → bool
isSameMinute(DateTime other) → bool
isSameMonth(DateTime other) → bool
isSameOrAfter(DateTime other) → bool
isSameOrBefore(DateTime other) → bool
isSameSecond(DateTime other) → bool
isSameYear(DateTime other) → bool
isWithinInterval(Interval interval) → bool
isWithinRange(DateTime startDate, DateTime endDate) → bool
setDay(int day, [int hour, int minute, int second, int millisecond, int microsecond]) → DateTime
setWeekDay(int weekday, [int weekStartsOn]) → DateTime
setHour(int hour, [int minute, int second, int millisecond, int microsecond]) → DateTime
setMicrosecond(int microsecond) → DateTime
setMillisecond(int millisecond, [int microsecond]) → DateTime
setMinute(int minute, [int second, int millisecond, int microsecond]) → DateTime
setMonth(int month, [int day, int hour, int minute, int second, int millisecond, int microsecond]) → DateTime
setSecond(int second, [int millisecond, int microsecond]) → DateTime
setYear(int year, [int month, int day, int hour, int minute, int second, int millisecond, int microsecond]) → DateTime
sub(Duration duration) → DateTime
subDays(int amount) → DateTime
subHours(int amount) → DateTime
subMicroseconds(dynamic amount) → DateTime
subMilliseconds(dynamic amount) → DateTime
subMinutes(dynamic amount) → DateTime
subMonths(dynamic amount) → DateTime
subSeconds(dynamic amount) → DateTime
subtract(Duration duration) → DateTime
subYears(dynamic amount) → DateTime
timeago({String locale, DateTime clock, bool allowFromNow}) → String
toHumanString() → String
Operators
operator <(DateTime other) → bool
operator <=(DateTime other) → bool
operator >(DateTime other) → bool
operator >=(DateTime other) → bool
operator -(Duration other) → DateTime
operator +(Duration other) → DateTime
Static Properties
endOfToday → DateTime
endOfTomorrow → DateTime
endOfYesterday → DateTime
startOfToday → DateTime
today → DateTime
tomorrow → DateTime
yesterday → DateTime
Static Methods
areRangesOverlapping(DateTime initialRangeStartDate, DateTime initialRangeEndDate, DateTime comparedRangeStartDate, DateTime comparedRangeEndDate) → bool
compareAsc(DateTime dateLeft, DateTime dateRight) → int
compareDesc(DateTime dateLeft, DateTime dateRight) → int
fromSecondsSinceEpoch(int secondsSinceEpoch, {bool isUtc: false}) → DateTime
isDate(dynamic argument) → bool
max(DateTime left, DateTime right) → DateTime
min(DateTime left, DateTime right) → DateTime
parse(String dateString, {String pattern, String locale: 'en_US', bool isUTC: false}) → DateTime
unix(int seconds) → DateTime
Interval class
// Constructors
Interval(DateTime start, DateTime end)

// Properties
duration → Duration
end → DateTime
hashCode → int
runtimeType → Type
start → DateTime

// Methods
contains(Interval interval) → bool
cross(Interval other) → bool
difference(Interval other) → Interval
equals(Interval other) → bool
includes(DateTime date) → bool
intersection(Interval other) → Interval
symetricDiffetence(Interval other) → List<Interval>
toString() → String
union(Interval other) → Interval

// Operators
operator <(Interval other) → bool
operator <=(Interval other) → bool
operator ==(dynamic other) → bool
operator >(Interval other) → bool
operator >=(Interval other) → bool
Duration Class
// Operators
operator -(Duration other) → Duration
operator +(Duration other) → Duration
operator *(num other) → Duration
operator /(num other) → Duration

카테고리

의존성

의존성 목록 2 개

소스 저장소

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