constructLocalizedDateTime function
DateTime
constructLocalizedDateTime(
- int year, [
- int month = 1,
- int day = 1,
- int hour = 0,
- int minute = 0,
- int second = 0,
- int millisecond = 0,
- int microsecond = 0,
])
Implementation
DateTime constructLocalizedDateTime(
int year, [
int month = 1,
int day = 1,
int hour = 0,
int minute = 0,
int second = 0,
int millisecond = 0,
int microsecond = 0,
]) {
try {
// Attempt to get timezone from localization
final localization = Get.find<Localization>();
if (localization.timezone == null) {
return DateTime(
year,
month,
day,
hour,
minute,
second,
millisecond,
microsecond,
);
}
return TZDateTime(
localization.timezoneLocation!,
year,
month,
day,
hour,
minute,
second,
millisecond,
microsecond,
);
} catch (e) {
// If there's an error, fallback to the original dateTime constructor
return DateTime(
year,
month,
day,
hour,
minute,
second,
millisecond,
microsecond,
);
}
}