date_x 1.0.0 copy "date_x: ^1.0.0" to clipboard
date_x: ^1.0.0 copied to clipboard

A lightweight Dart library for date manipulation and formatting.

date_x #

A lightweight Dart library for date manipulation and formatting. This package provides a simple and intuitive way to work with dates in Dart applications.

Features #

  • Create dates with validation
  • Parse dates from strings in various formats
  • Format dates with custom separators
  • Convert between Date and DateTime objects
  • Handle leap years and month boundaries correctly
  • Get current date
  • Comprehensive equality checking

Getting started #

Add date_x to your pubspec.yaml:

dependencies:
  date_x: ^1.0.0

Then run dart pub get.

Usage #

Here are some examples of how to use the date_x package:

Creating a Date #

// Create a date using the constructor
final date = Date(year: 2023, month: 12, day: 25);

Parsing Dates #

// Parse date from YYYYMMDD format
final date1 = Date.parse('20231225');

// Parse date with separators
final date2 = Date.parse('2023-12-25', separator: '-');
final date3 = Date.parse('2023.12.25', separator: '.');

Formatting Dates #

final date = Date(year: 2023, month: 12, day: 25);

// Format without separator (default)
print(date.toString()); // 20231225

// Format with custom separators
print(date.toString(separator: '-')); // 2023-12-25
print(date.toString(separator: '.')); // 2023.12.25
print(date.toString(separator: '/')); // 2023/12/25

Working with Current Date #

// Get current date
final currentDate = Date.current();

Converting to DateTime #

final date = Date(year: 2023, month: 12, day: 25);
final dateTime = date.toDateTime(); // Convert to DateTime

Additional information #

The date_x package is designed to be simple and efficient for date operations in Dart. It handles edge cases like leap years and month boundaries automatically.

For more information, check the API documentation.

Contributions are welcome! Please feel free to submit issues or pull requests on GitHub.

This package is maintained by the community. For questions or support, please open an issue on the repository.

1
likes
140
points
15
downloads

Publisher

unverified uploader

Weekly Downloads

A lightweight Dart library for date manipulation and formatting.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

More

Packages that depend on date_x