getCurrentTimezone method

  1. @override
Future<String> getCurrentTimezone()
override

Gets the current device's IANA timezone string.

Returns the timezone identifier from the device's system settings (e.g., "America/New_York", "Europe/London", "Asia/Tokyo").

This value includes DST rules and is the authoritative source for local time calculations on the backend.

Returns

The IANA timezone identifier string.

Example

final timezone = await deviceService.getCurrentTimezone();
print('Timezone: $timezone');
// Output: Timezone: America/New_York

Implementation

@override
Future<String> getCurrentTimezone() async {
  try {
    final timezoneInfo = await FlutterTimezone.getLocalTimezone();
    return timezoneInfo.identifier;
  } catch (e) {
    loge(e, 'DeviceService: Failed to get timezone');
    // Return UTC as fallback - this is a safe default
    return 'UTC';
  }
}