from datetime import date, timedelta


def get_date_from_now(nb_days):
    return date.today() - timedelta(days=nb_days)


def get_date_diff(date_a, date_b):
    return abs((date_b - date_a).total_seconds())

from babel.dates import format_datetime
from datetime import date, datetime, timedelta


def get_date_from_now(nb_days):
    return date.today() - timedelta(days=nb_days)


def get_date_diff(date_a, date_b):
    return abs((date_b - date_a).total_seconds())


def get_date_string_with_timezone(date_string, timezone):
    """
    Apply given timezone to given date and return it as a string.
    """
    date_obj = datetime.strptime(date_string, "%Y-%m-%dT%H:%M:%S")
    return format_datetime(
        date_obj,
        "YYYY-MM-DDTHH:mm:ss",
        tzinfo=timezone
    )

Add helper to handle timezone in date strings
[utils] Add helper to handle timezone in date strings

+ from babel.dates import format_datetime
- from datetime import date, timedelta
+ from datetime import date, datetime, timedelta
  
  
  def get_date_from_now(nb_days):
      return date.today() - timedelta(days=nb_days)
  
  
  def get_date_diff(date_a, date_b):
      return abs((date_b - date_a).total_seconds())
  
+ 
+ def get_date_string_with_timezone(date_string, timezone):
+     """
+     Apply given timezone to given date and return it as a string.
+     """
+     date_obj = datetime.strptime(date_string, "%Y-%m-%dT%H:%M:%S")
+     return format_datetime(
+         date_obj,
+         "YYYY-MM-DDTHH:mm:ss",
+         tzinfo=timezone
+     )
+ 
Add helper to handle timezone in date strings
## Code Before:
from datetime import date, timedelta


def get_date_from_now(nb_days):
    return date.today() - timedelta(days=nb_days)


def get_date_diff(date_a, date_b):
    return abs((date_b - date_a).total_seconds())

## Instruction:
Add helper to handle timezone in date strings
## Code After:
from babel.dates import format_datetime
from datetime import date, datetime, timedelta


def get_date_from_now(nb_days):
    return date.today() - timedelta(days=nb_days)


def get_date_diff(date_a, date_b):
    return abs((date_b - date_a).total_seconds())


def get_date_string_with_timezone(date_string, timezone):
    """
    Apply given timezone to given date and return it as a string.
    """
    date_obj = datetime.strptime(date_string, "%Y-%m-%dT%H:%M:%S")
    return format_datetime(
        date_obj,
        "YYYY-MM-DDTHH:mm:ss",
        tzinfo=timezone
    )
