srawlins / timezone

Time zone database and time zone aware DateTime object for Dart.
BSD 2-Clause "Simplified" License
101 stars 52 forks source link

Are raw GMT offsets inverted? #161

Closed davidcesarino closed 1 year ago

davidcesarino commented 1 year ago

Library version: 0.9.0

Code:

import 'package:timezone/timezone.dart';
import 'package:timezone/data/latest_all.dart' as tz;

tz.initializeTimeZones();
final utcTime = TZDateTime.now(getLocation('Etc/UTC'));
final localTime = TZDateTime.from(utcTime, getLocation('America/Recife'));
final gmtL3 = TZDateTime.from(utcTime, getLocation('Etc/GMT-3'));

print('UTC Time: ' + utcTime.toString());
print('Recife Time: ' + localTime.toString());
print('GMT-3 Time: ' + gmtL3.toString());`

Output is:

UTC Time: 2023-03-24 03:55:59.485852+0000
Recife Time: 2023-03-24 00:55:59.485852-0300
GMT-3 Time: 2023-03-24 06:55:59.485852+0300

I can attest that UTC and Recife time are shown correctly and match the time at the moment I tested it.

However, it looks like GMT-3 has been switched with GMT+3. The notation at the end seems to indicate this, and indeed the time displayed seems wrong to me, as GMT-3 should be 3 hours before UTC, and not after UTC. AFAIK, this happens with all "GMT-?" or "GMT+?" locations in the library. When I debug the library I can see it loads the switched int offsets as well (of course).

Is this really a bug or am I missing something here? Is this a mistake in the library or in the

juaoose commented 1 year ago

GMT-3 is not the same as Etc/GMT-3

https://en.wikipedia.org/wiki/List_of_tz_database_time_zones

davidcesarino commented 1 year ago

GMT-3 is not the same as Etc/GMT-3

https://en.wikipedia.org/wiki/List_of_tz_database_time_zones

You're right, my mistake. Closing.