getCurrentLocalizedDateTime function

DateTime getCurrentLocalizedDateTime()

Implementation

DateTime getCurrentLocalizedDateTime() {
  try {
    // Attempt to get timezone from localization
    final localization = Get.find<Localization>();
    if (localization.timezone == null) {
      return DateTime.now();
    }

    return TZDateTime.now(localization.timezoneLocation!);
  } catch (e) {
    // If there's an error, fallback to the original dateTime
    return DateTime.now();
  }
}