date_time 0.4.5 copy "date_time: ^0.4.5" to clipboard
date_time: ^0.4.5 copied to clipboard

outdated

Package to work with Date & Time in separation and with its Ranges.

pub package codecov likes style: lint Dart

date_time #

Package to work with Date & Time in separation and with its ranges.

This project will be useful for projects that are related to booking.

Features #

  • Only Date comparison
  • Only Time comparison
  • Overflowed Time with keeping days
  • Find crossing of dates
  • Find crossing of times in the day

Getting started #

  1. Add dependency
dependencies:
  date_time: <newest>
  1. Import the dependency
import 'package:date_time/date_time.dart';

Usage #

Please, check (examples) folder for more advanced examples.

Date #

given('DateTime', () {
  final dateTime = DateTime(2020, 11, 30, 14, 33, 17);

  then('date should be equal to', () {
    dateTime.date.should.be(Date(2020, 11, 30));
  });

  then('time should be equal to', () {
    dateTime.time.should.be(Time(14, mins: 33, secs: 17));
  });
});

DateRange #

final range = DateRange(
  const Date(2021, 1, 1),
  const Date(2021, 12, 31),
);

test('should be valid', () {
  range.isValid.should.beTrue();
});

Time #

final time2 = time.addMinutes(30);
final isTime2After = time2 > time;
final isTime2After2 = time2.isAfter(time);
print('Is time2 after: $isTime2After');

Overflowed Time #

to keep days

final time = Time(20).addHours(5);

print(time is OverflowedTime); // prints `true`
print(time.asOverflowed.days); // prints `1`

TimeRange #

// TimeRange crossing
final timeRange = TimeRange(Time.now, Time.now.addHours(6));
final timeRange2 = TimeRange(Time.now.addHours(3), Time.now.addHours(9));

final isCrossing = timeRange.isCross(timeRange2);
print('Time ranges are crossing: $isCrossing');

Contributing #

We accept the following contributions:

  • New features
  • Improving documentation
  • Reporting issues
  • Fixing bugs

Maintainers #

17
likes
0
pub points
87%
popularity

Publisher

verified publisherdevcraft.ninja

Package to work with Date & Time in separation and with its Ranges.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

quiver

More

Packages that depend on date_time