date_time_iso

Creator: coderz1093

Last updated:

0 purchases

date_time_iso Image
date_time_iso Images

Languages

Categories

Add to Cart

Description:

date time iso

date_time_iso #
date_time, but ISO
Package to work with date & time in separation and with its ranges.
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 #

Add dependency

dependencies:
date_time_iso: <newest>
copied to clipboard

Import the dependency

import 'package:date_time_iso/date_time_iso.dart';
copied to clipboard
Usage #
Please, check (examples) folder for more advanced examples.
Date #
// Get [Date] & [Time] from [DateTime]
print(DateTime(2022, 1, 6).date); // prints 1/6/2022
print(DateTime(7, 38, 24).time); // 07:38:24
copied to clipboard
given('DateTime', () {
final dateTime = DateTime(2020, 11, 30, 14, 33, 17);

then('[Date] should be equal to', () {
dateTime.date.should.be(Date(year: 2020, month: 11, day: 30));
});

then('[Time] should be equal to', () {
dateTime.time.should.be(Time(hour: 14, minute: 33, second: 17));
});
});
copied to clipboard
CopyWith
final date = Date(year: 2021, month: 3, day: 7);
print(date.copyWith(year: 2022)); // prints 07/03/2022
copied to clipboard
DateRange #
final range = DateRange(
const Date(year: 2021, month: 1, day: 1),
const Date(year: 2021, month: 1, day: 3),
);

inspect(range.toList()) // [2021-01-01, 2021-01-02, 2021-01-03]
copied to clipboard
Time #
final time2 = time.addMinutes(30);
final isTime2After = time2 > time;
final isTime2After2 = time2.isAfter(time);
print('Is time2 after: $isTime2After');
copied to clipboard
CopyWith
final time = Time(hour: 6, minute: 30, second: 7);
print(time); // prints 06:30:07
print(time.copyWith(second: 0)); // prints 06:30:00
copied to clipboard
Overflowed Time #
to keep days
final time = Time(hour: 20).addHours(5);

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

copied to clipboard
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');
copied to clipboard
Override time with clock package #
withClock(
Clock(() => DateTime.now().subtract(Duration(days: 10, minutes: 214))),
() {
print(clock.now()); // 2022-06-21 16:28:46.366887
print(DateTime.now()); // 2022-07-01 20:02:46.367579
print('${Date.now()} ${Time.now()}'); // 6/21/2022 16:28:46
},
);
copied to clipboard
Changelog #
Please see the Changelog page to know what's recently changed.
Contributing #
Feel free to contribute to this project.
If you find a bug or want a feature, but don't know how to fix/implement it, please fill an issue.
If you fixed a bug or implemented a new feature, please send a pull request.
We accept the following contributions:

New features
Improving documentation
Fixing bugs

Maintainers #
This fork: #

XperiTech

xperitech.com
Base repo: #

Andrew Piterov

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.