date_time_converter 0.0.5 copy "date_time_converter: ^0.0.5" to clipboard
date_time_converter: ^0.0.5 copied to clipboard

A Dart package for handling and converting DateTime, Duration, and Timestamp with rounding, formatting, and utility functions.

date_time_converter #

A Dart package that provides utilities for date and time conversion, formatting, and manipulation. This package includes extensions and helper classes to simplify working with DateTime, Duration, and timestamps.

Features #

  • Round DateTime objects up or down to the nearest 10 minutes.
  • Format Duration and DateTime objects into readable strings.
  • Convert integers to formatted time strings.
  • Convert timestamps to DateTime objects and vice versa.
  • Parse and format dates into different string representations.
  • Calculate delays in days between two dates.
  • Format dates as human-readable relative strings (e.g., "Yesterday", "Mon, 12 Jul").

Installation #

Add the following to your pubspec.yaml file:

dependencies:
  date_time_converter: latest_version

Then, run:

flutter pub get

Usage #

Import the package #

import 'package:date_time_converter/date_time_converter.dart';

Rounding DateTime #

DateTime now = DateTime.now();
DateTime roundedUp = now.roundUpToNearestTenMinutes();
DateTime roundedDown = now.roundDownToNearestTenMinutes();

Formatting Duration #

Duration duration = Duration(hours: 2, minutes: 30, seconds: 45);
String formatted = duration.formatHoursMinutesSeconds();
print(formatted); // Output: 02:30:45

Integer to Time String #

int totalSeconds = 3661;
String timeString = totalSeconds.toTimeString();
print(timeString); // Output: 01:01:01

Date Conversion & Formatting #

DateTime now = DateTime.now();
String formattedDate = DateUtilsDateFormatImpl().convertDateToString(now);
print(formattedDate);

Timestamp Conversion #

Timestamp timestamp = Timestamp.now();
DateTime dateTime = TimeStampUtilsImpl().convertDateTimeToTimeStamp(timestamp)!;

Contributions #

Contributions are welcome! Feel free to submit a pull request or open an issue.

License #

This package is released under the MIT License.

0
likes
150
points
22
downloads

Publisher

unverified uploader

Weekly Downloads

A Dart package for handling and converting DateTime, Duration, and Timestamp with rounding, formatting, and utility functions.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

cloud_firestore, date_format, flutter, intl

More

Packages that depend on date_time_converter