date_formatter_codespark 1.3.1 copy "date_formatter_codespark: ^1.3.1" to clipboard
date_formatter_codespark: ^1.3.1 copied to clipboard

A zero-dependency Dart and Flutter date formatter with DateTime extensions for date formatting, datetime formatting, relative time, time ago, human-readable dates, timestamps, and custom date formats.

date_formatter_codespark #

A zero-dependency, ultra-lightweight date formatter and DateTime extension package for Dart and Flutter.

Format dates, format DateTime values, generate human-readable dates, create relative timestamps ("5m ago"), display time ago strings, perform business day calculations, and work with weeks, months, quarters, and years through a clean, fluent API.

Perfect as a lightweight alternative to intl for date formatting and a replacement for timeago when displaying relative time and human-readable timestamps.

Built by Katayath Sai Kiran · @Katayath-Sai-Kiran

pub version pub points pub likes MIT License platform: flutter DateTime Extensions

Perfect For #

  • Formatting dates
  • Formatting DateTime values
  • Time ago displays
  • Relative timestamps
  • Human-readable dates
  • Chat applications
  • Social feeds
  • Activity timelines
  • Notifications
  • Logs and analytics

Common Use Cases #

  • Date formatting
  • DateTime formatting
  • Date formatter replacement
  • Intl alternative
  • Time ago formatting
  • Relative time displays
  • Relative timestamp formatting
  • Timestamp formatting
  • Human-readable timestamps
  • Chat message timestamps
  • Activity feed timestamps
  • Notification timestamps
  • Calendar applications
  • Business day calculations
  • Date utilities
  • Date extension utilities

Screenshots #

[Variables & Relative Time] [Calendar Flags]
Variables & Relative Time Calendar Flags
[Business Day Logic] [Week / Month / Year Boundaries]
Business Day Logic Week / Month / Year Boundaries
[Date Math & Formatting] [Holiday, Fiscal & Julian Day]
Date Math & Formatting Holiday, Fiscal & Julian Day

Date Formatter Example #

final now = DateTime.now();

now.toFullHumanDate();   // Friday, 29 May, 2026
now.toIsoDateString();   // 2026-05-29
now.toShortDateString(); // 05/29/2026

The Token-Saving Advantage (Before vs. After) #

1. Relative Human Time #

Without this package (30 lines of error-prone math):

String timeAgo(DateTime date) {
  final diff = DateTime.now().difference(date);
  if (diff.inMinutes < 60) return '${diff.inMinutes}m ago';
  if (diff.inHours < 24) return '${diff.inHours}h ago';
  return '${diff.inDays}d ago';
}

With this package (1 line):

dateTime.toTimeAgo(); // "5m ago"

2. Live Countdown Tracking #

Without this package: Manual epoch calculations checking for midnight boundaries.

With this package:

dueDate.daysRemaining(); // "3 days left"

Key Features & Usage #

Semantic Evaluation Flags #

dateTime.isToday;        // true/false
dateTime.isYesterday;    // true/false
dateTime.isTomorrow;     // true/false
dateTime.isThisWeek;     // true/false
dateTime.isWeekend;      // true/false
dateTime.isBusinessDay;  // true/false
dateTime.isLastBusinessDayOfMonth; // true/false
dateTime.isLeapYear;     // true/false
dateTime.isFuture;       // true/false
dateTime.isPast;         // true/false

Date Formatting & DateTime Formatter Presets #

dateTime.toDayAndMonth();     // "29 May"
dateTime.toTime12Hour();      // "11:30 PM"
dateTime.toFullHumanDate();   // "Friday, 29 May, 2026"
dateTime.toIsoDateString();   // "2026-05-29"
dateTime.toIsoTimeString();   // "09:05:07"
dateTime.toShortTimeString(); // "9:05 AM"
dateTime.toShortDateString(); // "05/30/2026"
dateTime.toRfc2822String();   // "Sat, 30 May 2026 09:05:00 +0000"

Relative Time & Time Ago Formatting #

dateTime.toTimeAgo();               // "12m ago"  (short, default)
dateTime.toTimeAgo(short: false);   // "12 minutes ago"  (verbose)

// Future dates work natively:
dateTime.toTimeAgo(); // "in 3h"
dateTime.toTimeAgo(short: false); // "in 3 hours"

Precise Time Countdowns #

dateTime.daysRemaining();  // "3 days left" | "1 day left" | "Today" | "Expired"
dateTime.hoursRemaining(); // "5 hours left" | "1 hour left" | "Expired"

Business Day & Calendar Math #

dateTime.addBusinessDays(3);      // Skips weekends
dateTime.subtractBusinessDays(2); // Skips weekends
dateTime.nextDay;                 // Next calendar day
dateTime.previousDay;             // Previous calendar day
dateTime.copyWith(year: 2027);    // Clone with changes

Week, Month, Quarter, Year Utilities #

dateTime.weekOfYear;        // ISO week number
dateTime.quarter;           // 1-4
dateTime.isQuarterStart;    // true/false
dateTime.isQuarterEnd;      // true/false
dateTime.startOfWeek;       // Monday
dateTime.endOfWeek;         // Sunday
dateTime.startOfMonth;      // First day
dateTime.endOfMonth;        // Last day
dateTime.startOfYear;       // Jan 1
dateTime.endOfYear;         // Dec 31
dateTime.isFirstDayOfMonth; // true/false
dateTime.isLastDayOfMonth;  // true/false
dateTime.daysInMonth;       // 28-31
dateTime.isSameDay(other);
dateTime.isSameWeek(other);
dateTime.isSameMonth(other);
dateTime.isSameYear(other);

Julian Day Support #

dateTime.toJulianDay;                  // int
DateFormatterExtension.fromJulianDay(2451545); // DateTime

Date Math & Utilities #

dateTime.daysUntil(other);        // int
dateTime.monthsBetween(other);    // int
dateTime.yearsBetween(other);     // int
dateTime.isWithin(start, end);    // true/false
dateTime.atTime(9, 30);           // Set time
dateTime.endOfDay;                // 23:59:59.999
dateTime.withTimeZoneOffset(Duration(hours: 2));
dateTime.toLocalOrUtc();

Installation #

Add to your pubspec.yaml:

dependencies:
  date_formatter_codespark: ^1.3.0

Then import:

import 'package:date_formatter_codespark/date_formatter_codespark.dart';

Zero Dependencies #

This package has no external dependencies. It does not use intl, timeago, or any other third-party package. All date formatting, locale-aware month names, and weekday strings are handled via lean, hand-crafted lookup tables internally.

Full API Reference #

All extension methods are documented with concise doc comments and examples in the code. See lib/src/date_extensions.dart for the complete API surface.

License #

MIT License — see LICENSE for details.

8
likes
0
points
264
downloads

Publisher

verified publisherksaikiran.dev

Weekly Downloads

A zero-dependency Dart and Flutter date formatter with DateTime extensions for date formatting, datetime formatting, relative time, time ago, human-readable dates, timestamps, and custom date formats.

Homepage
Repository (GitHub)
View/report issues

Topics

#date-formatting #datetime #date-formatter #time-ago #datetime-extension

License

unknown (license)

Dependencies

flutter

More

Packages that depend on date_formatter_codespark