From 4bc688c7d41248e269bdc71d63372d32dd4f92f0 Mon Sep 17 00:00:00 2001 From: Kevin Cole Date: Fri, 31 Jul 2026 16:25:09 -0400 Subject: [PATCH 1/2] Fix DepreciationWarning. Use timezone-aware objects. --- gbfs/examples/basic_usage.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/gbfs/examples/basic_usage.py b/gbfs/examples/basic_usage.py index 1c3abd6..f6ab7bd 100644 --- a/gbfs/examples/basic_usage.py +++ b/gbfs/examples/basic_usage.py @@ -3,7 +3,6 @@ from gbfs.services import SystemDiscoveryService - def example(): ds = SystemDiscoveryService() @@ -54,14 +53,12 @@ def example(): statuses = station_status.get('data').get('stations') first_station_status = [s for s in statuses if s.get('station_id') == first_station.get('station_id')][0] - staleness = datetime.datetime.utcnow() - station_status.get('last_updated') - + staleness = datetime.datetime.now(datetime.UTC).replace(tzinfo=None) - station_status.get('last_updated') print('Station {} has a total capacity of {} and (as of {} seconds ago) has {} bikes available for rent.'.format( first_station.get('name'), first_station.get('capacity'), staleness.seconds, first_station_status.get('num_bikes_available'))) print('') - if __name__ == '__main__': example() From 534be2d8060d4e928bb9cf7d08b56718351cc3de Mon Sep 17 00:00:00 2001 From: Kevin Cole Date: Fri, 31 Jul 2026 16:27:24 -0400 Subject: [PATCH 2/2] Make station_status time-zone-aware instead of making now unaware --- gbfs/examples/basic_usage.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gbfs/examples/basic_usage.py b/gbfs/examples/basic_usage.py index f6ab7bd..3b0392c 100644 --- a/gbfs/examples/basic_usage.py +++ b/gbfs/examples/basic_usage.py @@ -2,6 +2,7 @@ from gbfs.services import SystemDiscoveryService +import pytz def example(): ds = SystemDiscoveryService() @@ -53,7 +54,7 @@ def example(): statuses = station_status.get('data').get('stations') first_station_status = [s for s in statuses if s.get('station_id') == first_station.get('station_id')][0] - staleness = datetime.datetime.now(datetime.UTC).replace(tzinfo=None) - station_status.get('last_updated') + staleness = datetime.datetime.now(datetime.UTC) - station_status.get('last_updated').replace(tzinfo=pytz.utc) print('Station {} has a total capacity of {} and (as of {} seconds ago) has {} bikes available for rent.'.format( first_station.get('name'), first_station.get('capacity'), staleness.seconds, first_station_status.get('num_bikes_available')))