A Dart package to help you with managing dates easily.

Overview

๐Ÿ“† Dateable

Pub Buy Me A Coffee

A Dart package to help you with managing dates easily. Can be used to store, format, convert, construct, parse and serialise dates. Calendar correctness is guaranteed by the usage of DateTime's system under the hood.

โš™๏ธ Import

In your .dart files:

import 'package:dateable/dateable.dart';

โš—๏ธ Usage

๐Ÿ‘ท Constructors

Variety of different constructors allows for great flexibility and interoperability with other types.

final date = Date(31, 12, 2019);
final date = Date.fromDateTime(DateTime(2019, 12, 31, 19, 1)); // Time of day is truncated
final date = Date.parseIso8601('2019-12-31T18:23:48.956871'); // Time of day is truncated
final date = Date.parse('31122019');
final date = Date.today();
final date = Date.yesterday();
final date = Date.tomorrow();

And a handy DateTime extension:

final date = DateTime(2019, 12, 31, 13, 26).toDate(); // Time of day is truncated

All of the above result in the same date object!

๐Ÿ“… Getters

There are three getters. Simple and easy.

final date = Date(11, 3, 2002);
print(date.day); // Prints 11
print(date.month); // Prints 3
print(date.year); // Prints 2002

โ†”๏ธ Conversion methods

Date allows for seamless and easy conversions to most commonly used representations!

final date = Date(11, 3, 2002);
final dateTime = date.toDateTime(); // Time of day is set to zeros
print(date.toIso8601()); // Prints 2002-03-11T00:00:00.000
print(date.toString()); // Prints 11032002

๐Ÿ“Š Comparisions

Comparisions work just like in your well-known DateTime objects!

final earlier = Date(11, 3, 2002);
final later = Date(21, 9, 2004);
print(earlier.isBefore(later)); // True
print(later.isAfter(earlier)); // Also true

On top of this, there are also operators > (is after) , < (is before), <=, >= and ==.

Here comes another handy DateTime extension:

DateTime(2002, 3, 11, 14, 56, 28).isTheSameDate(Date(11, 3, 2002));

But if all you want is to check if your Date is nearby, here you are.

final date = Date(11, 3, 2002);
date.isToday();
date.isYesterday();
date.isTomorrow();

๐Ÿ“ฐ Formatting

You can format your Dates to Strings both with top-level constants and with String literals:

  • yyyy - 4 digit year, i.e. 1997
  • yy - 2 digit year, i.e. 97
  • mm - 2 digit month, i.e. 03
  • dd - 2 digit day, i.e. 11

Both of the below options are correct:

Date(11, 3, 2002).format([dd, '-', mm, '-', yyyy])
Date(11, 3, 2002).format(['dd', '-', 'mm', 'yyyy'])

๐Ÿ”จ Modifiers

Last but not least, there is a set of useful modifiers. Every Date object is immutable by default, so each of them creates a new Date object.

date.addDays(2) == date + 2 // Always true
date.subtractDays(7) == date - 7 // Also always true

You can also use the idiomatic copyWith function.

date.copyWith(day: 21, month: 9);

Sorting an Iterable of Dates chronologically is even easier:

[Date(21, 9, 2004), Date(24, 12, 2006), Date(11, 3, 2002)].sort((a, b) => a.compareTo(b));

Now the list is [Date(11, 3, 2002), Date(21, 9, 2004), Date(24, 12, 2006)].

๐Ÿ› Contributing / bug reporting

Contributions and bug reports are welcome! Feel free to open an issue or create a pull request.

๐Ÿ“– License

This package is distributed under MIT license.

You might also like...

A Flutter package for using Jalali (Shamsi, Solar, Persian or Jalaali) calendar. You can convert, format and manipulate Jalali and Gregorian (Miladi) dates.

A Flutter package for using Jalali (Shamsi, Solar, Persian or Jalaali) calendar. You can convert, format and manipulate Jalali and Gregorian (Miladi) dates.

A Flutter package for using Jalali (Shamsi, Solar, Persian or Jalaali) calendar. You can convert, format and manipulate Jalali and Gregorian (Miladi) dates.

Dec 21, 2022

A package that exports functions for converting, formatting, and nicening of dates/times in Dart.

Instant A library for manipulating and formatting DateTimes in Dart. Dates and times have never been easier. | DateTime timezone manipulation | Easy f

Jan 22, 2022

A Flutter package for iOS and Android for picking last seven dates and time with analog view.

analog_time_picker package for Flutter A Flutter package for iOS and Android for picking last seven dates and time with analog view. Demo Installation

Aug 31, 2021

A light weight library to easily manage a progress dialog with simple steps whenever you need to do it. You can easily show and hide it.

A light weight library to easily manage a progress dialog with simple steps whenever you need to do it. You can easily show and hide it.

progress_dialog A light weight package to show progress dialog. As it is a stateful widget, you can change the text shown on the dialog dynamically. T

Dec 11, 2022

A most easily usable cookie management library in Dart. With SweetCookieJar, you can easily manage cookie on your application.

A most easily usable cookie management library in Dart. With SweetCookieJar, you can easily manage cookie on your application.

A most easily usable cookie management library in Dart! 1. About 1.1. Introduction 1.1.1. Install Library 1.1.2. Import It 1.1.3. Use SweetCookieJar 1

Oct 27, 2022

A most easily usable cache management library in Dart. With CacheStorage, you can easily manage cache on your application.

A most easily usable cache management library in Dart! 1. About 1.1. Introduction 1.1.1. Install Library 1.1.2. Import It 1.1.3. Use CacheStorage 1.2.

Dec 13, 2021

A most easily usable RESAS API wrapper in Dart. With this library, you can easily integrate your application with the RESAS API.

A most easily usable RESAS API wrapper library in Dart! 1. About 1.1. What Is RESAS? 1.2. Introduction 1.2.1. Install Library 1.2.2. Import It 1.2.3.

Apr 7, 2022

A new flutter package project which contains lots of beautiful alert dialog that will help you lot to create beautiful awesome alert box very quickly and easily.

A new flutter package project which contains lots of beautiful alert dialog that will help you lot to create beautiful awesome alert box very quickly and easily.

A new flutter package project which contains lots of beautiful alert dialog that will help you lot to create beautiful awesome alert box very quickly and easily.

Jan 8, 2022

This package will help you to manage the overlays in your projects. Show a dialog, notification, window, or a panel easily

This package will help you to manage the overlays in your projects. Show a dialog, notification, window, or a panel easily

This package will help you to manage the overlays in your projects. Show a dialog, notification, window, or a panel easily. or use one of the helping widgets like AutoComplete, Expander(Dropdown).

Dec 4, 2022

This package helps developer to sort the flutter/dart packages and plugins alphabetically, This makes it easier when managing too many packages and when working with teams

This package helps developer to sort the flutter/dart packages and plugins alphabetically, This makes it easier when managing too many packages and when working with teams

Package helps to sort the flutter/dart packages and plugins alphabetically, This makes it easier when managing too many packages and when working with

Dec 21, 2022

Money_manager - This app helps you with managing Income and Expense

Money_manager - This app helps you with managing Income and Expense

Expense App This app helps you with managing Income and Expense. It is coded in flutter, dart hive. TBH I want to code the same app in Flutter , React

Nov 14, 2022

Flutter file manager - Flutter package for managing files on Android

Flutter file manager - Flutter package for managing files on Android

flutter_file_utils Helper tools for managing files on Android. Getting Started For help getting started with Flutter, view our online documentation. F

Nov 11, 2022

A package help you to make api call and handle error faster, also you can check for internet before call api.

http_solver ##not for production use, only for learning purpose. A package help you to make api call and handle error faster, also you can check for i

Jun 18, 2020

Flutter package that provides you custom clippers to help you achieve various custom shapes.

Flutter package that provides you custom clippers to help you achieve various custom shapes.

flutter_custom_clippers Flutter package that provides you custom clippers to help you achieve various custom shapes. Usage To use this plugin, add flu

Dec 23, 2022

A package that lets you include a cool, nice looking and validated Password TextFormField in your app to enhance user experience. The package is fully & easily modifiable.

A package that lets you include a cool, nice looking and validated Password TextFormField in your app to enhance user experience. The package is fully & easily modifiable.

A package that lets you include a cool, nice looking and validated Password TextFormField in your app to enhance user experience. The package is fully

Jan 1, 2023

A package that lets you include a cool, nice looking and validated Password TextFormField in your app to enhance user experience. The package is fully & easily modifiable.

A package that lets you include a cool, nice looking and validated Password TextFormField in your app to enhance user experience. The package is fully & easily modifiable.

A package that lets you include a cool, nice looking and validated Password TextFormField in your app to enhance user experience. The package is fully

Jun 7, 2022

Chance Dart is a free Open Source project that lets you create random strings, integers, and other things to help with tiresome tasks, especially when building automated tests or wherever else you require anything random.

 Chance Dart is a free Open Source project that lets you create random strings, integers, and other things to help with tiresome tasks, especially when building automated tests or wherever else you require anything random.

Chance Dart Random generator helper for Dart Homepage โ€ข Documentation Overview Chance Dart is a free Open Source project that lets you create random s

Dec 27, 2022

This package give you ability to integrate with Drone API easily in any platform using Dart

This package give you ability to integrate with Drone API easily in any platform using Dart

Drone Dart Dart is a multi client programming language which allow you to compile and run your code on multiple platforms. Because of that we decided

Dec 22, 2022
Owner
Jakub Krฤ…piec
Nice to meet you!
Jakub Krฤ…piec
A Flutter package allows you to easily implement all calendar UI and calendar event functionality. ๐Ÿ‘Œ๐Ÿ”๐ŸŽ‰

calendar_view A Flutter package allows you to easily implement all calendar UI and calendar event functionality. For web demo visit Calendar View Exam

Simform Solutions 219 Dec 22, 2022
Calendar widget for flutter that is swipeable horizontally. This widget can help you build your own calendar widget highly customizable.

flutter_calendar_carousel Calendar widget for flutter that is swipeable horizontally. This widget can help you build your own calendar widget highly c

dooboolab 750 Jan 7, 2023
A calendar widget to easily scroll through the years ๐Ÿ—“

Flutter Scrolling Calendar A customizable calendar widget to easily scroll through the years. Features Choose range of years and the initial year to s

Menno Renkens 113 Nov 19, 2022
A pure dart package with collection of Nepali Utilities like Date converter, Date formatter, DateTime, Nepali Numbers, Nepali Unicode, Nepali Moments and many more.

Nepali Utilities for Dart A pure dart package with collection of Nepali Utilities like Date converter, Date formatter, DateTime, Nepali Number, Nepali

Sarbagya Dhaubanjar 23 Nov 22, 2022
A Flutter package for adding a DateRange widget into a form. A date picker UX is provided by showDateRangePicker.

A Flutter package for adding a DateRange widget into a form. A date picker UX is provided by showDateRangePicker.

JMA Consulting 9 Mar 12, 2022
Flutter package to create a day date scroller

scrolling_day_calendar A flutter calendar package to allow users to scroll through given dates either by swiping left and right or pressing the arrows

null 8 Jul 12, 2020
Flutter calendar week UI package

Flutter calendar week Flutter calendar week UI package IOS | Android: import 'package:flutter_calendar_week/flutter_calendar_week.dart'; CalendarWeek(

null 67 Dec 12, 2022
A seasonal foods calendar app written in Dart using Flutter.

This project is not actively maintained anymore. However, everybody who wants to do so is more than welcome to work on this project! Thank you for you

Andreas Boltres 63 Nov 19, 2022
The Flutter plugin that help you can choose dates and years with rounded calendars and customizable themes.

Flutter Rounded Date Picker The Flutter plugin that help you can choose dates and years with rounded calendars and customizable themes. Installing Add

benznest 313 Dec 22, 2022
A Simple Todo app design in Flutter to keep track of your task on daily basis. Its build on BLoC Pattern. You can add a project, labels, and due-date to your task also you can sort your task on the basis of project, label, and dates

WhatTodo Life can feel overwhelming. But it doesnโ€™t have to. A Simple To-do app design in flutter to keep track of your task on daily basis. You can a

Burhanuddin Rashid 1k Jan 6, 2023