Skip to content

Commit

Permalink
✨ refactor trip date and time generation to use UTC+2 offset and ISO …
Browse files Browse the repository at this point in the history
…8601 format
  • Loading branch information
LokoMoloko98 committed Jan 25, 2025
1 parent 1dad100 commit d47be98
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions swift-lift-trips-table-ops/swift-lift-trips-table-ops.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import boto3
import json
from botocore.exceptions import ClientError
from datetime import datetime
import pytz # For timezone conversion
from datetime import datetime, timedelta, timezone

# Initialize DynamoDB
dynamodb = boto3.resource('dynamodb')
Expand All @@ -15,8 +14,10 @@ def generate_trip_date_time():
Returns:
str: The current date and time in ISO 8601 format (e.g., "2025-01-25T16:30:00+02:00").
"""
cat_tz = pytz.timezone("Africa/Johannesburg") # Central African Time
return datetime.now(cat_tz).strftime("%Y-%m-%dT%H:%M:%S%z")
# Define UTC+2 offset
utc_plus_2 = timezone(timedelta(hours=2))
now = datetime.now(utc_plus_2)
return now.isoformat(timespec="seconds")

def lambda_handler(event, context):
body = {}
Expand Down

0 comments on commit d47be98

Please sign in to comment.