getLocalizedDatetime function

DateTime getLocalizedDatetime(
  1. int gmtTimestamp,
  2. int localTimestamp
)

Implementation

DateTime getLocalizedDatetime(int gmtTimestamp, int localTimestamp) {
  final int localDiff = localTimestamp - gmtTimestamp;
  final Duration localOffset = Duration(milliseconds: localDiff);
  final DateTime gmtTime = DateTime.fromMillisecondsSinceEpoch(
    gmtTimestamp,
    isUtc: true,
  );
  // Dart's DateTime doesn't have a direct equivalent to astimezone with fixed offset in the same way Python does,
  // but we can add the offset.
  return gmtTime.add(localOffset);
}