jalali_date_time 1.0.2 copy "jalali_date_time: ^1.0.2" to clipboard
jalali_date_time: ^1.0.2 copied to clipboard

JalaliDateTime is a Dart package that provides a convenient way to work with Jalali (Persian) dates while using the underlying DateTime structure.

example/jalali_date_time_example.dart

// ignore_for_file: avoid_print

import 'package:jalali_date_time/jalali_date_time.dart';

void main() {
  // Create a JalaliDateTime instance for the current date and time
  final jalaliNow = JalaliDateTime.now();

  // Access Jalali components
  final year = jalaliNow.year;
  final month = jalaliNow.month;
  final day = jalaliNow.day;
  print('today: $year-$month-$day');
  // Convert JalaliDateTime to DateTime
  final dateTime = jalaliNow.toDateTime();

  // Perform DateTime operations
  final tomorrow = dateTime.add(const Duration(days: 1));
  final tyear = tomorrow.year;
  final tmonth = tomorrow.month;
  final tday = tomorrow.day;
  print('tomorrow: $tyear-$tmonth-$tday');
  // Convert DateTime back to JalaliDateTime
  final jalaliTomorrow = JalaliDateTime.fromDateTime(tomorrow);

  // Compare JalaliDateTime objects
  if (jalaliTomorrow.isAfter(jalaliNow)) {
    // ignore: prefer_single_quotes
    print("Tomorrow is after today.");
  }
}
1
likes
0
pub points
50%
popularity

Publisher

verified publishermoti.monster

JalaliDateTime is a Dart package that provides a convenient way to work with Jalali (Persian) dates while using the underlying DateTime structure.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

meta

More

Packages that depend on jalali_date_time