date_bin 2.0.0 copy "date_bin: ^2.0.0" to clipboard
date_bin: ^2.0.0 copied to clipboard

A Dart library that provides a dateBin function for binning timestamps into a specified interval aligned with a specified origin, similar to the date_bin function in Postgres.

example/date_bin_example.dart

import 'package:date_bin/date_bin.dart';
import 'package:intl/intl.dart';

void main() {
  Duration stride = Duration(minutes: 15);
  DateTime source = DateTime.parse('2020-02-11 15:44:17');
  DateTime origin = DateTime.parse('2001-01-01');

  DateTime binStart = dateBin(stride, source, origin);

  print(DateFormat('yyyy-MM-dd HH:mm:ss')
      .format(binStart)); // Output: 2020-02-11 15:30:00
}
1
likes
150
points
23
downloads

Publisher

verified publisherdatefirefly.com

Weekly Downloads

A Dart library that provides a dateBin function for binning timestamps into a specified interval aligned with a specified origin, similar to the date_bin function in Postgres.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

intl

More

Packages that depend on date_bin