from typing import Optional
from datetime import datetime
import pytz


def date_from_string(dtstr: str, fmt: str, timezone: str) -> Optional[datetime]:
    """Get datetime object from a date string.

    Args:
      dtstr: input date string
      fmt: datetime format string
      timezone: time zone string

    Returns:
      A datetime object if date string is provide else None
    """
    if not dtstr:
        return None
    return datetime.strptime(dtstr, fmt).replace(tzinfo=pytz.timezone(timezone))