getTimezone static method

Future<String> getTimezone()

Implementation

static Future<String> getTimezone() async {
  try {
    // Get timezone from environment or use UTC offset as fallback
    // For actual IANA timezone names, you may need platform channels
    // or initialize the timezone package with timezone data
    final now = DateTime.now();
    final offset = now.timeZoneOffset;
    final hours = offset.inHours;
    final minutes = offset.inMinutes.remainder(60);
    final sign = hours >= 0 ? '+' : '-';
    // Return UTC offset format (e.g., UTC+02:00)
    // For IANA timezone names like "Africa/Cairo", you'd need platform-specific implementation
    return 'UTC$sign${hours.abs().toString().padLeft(2, '0')}:${minutes.toString().padLeft(2, '0')}';
  } catch (e) {
    return 'UTC';
  }
}