Skip to main content
def process_date(
    date_string: str,
) -> datetime | None
Key Features:
  • Returns only the date part (year, month, day)
  • Time is always set to 00:00:00
  • Supports multiple international formats
  • Handles timezones and AM/PM formats
Parses various date string formats into datetime objects, returning only the date part with time set to midnight. This utility function provides robust date parsing capabilities for a wide range of common formats.

Supported Formats

The function handles these date format categories:

Standard Date Formats

  • DD/MM/YYYY: “22/11/2024”, “13/12/2024”
  • MM/DD/YYYY: “01/17/2025”, “10/25/2024”
  • Single-digit variants: “8/16/2019”, “9/28/2024”

Date-Time Combinations

  • With 24-hour time: “22/11/2024 21:19:05”
  • With AM/PM: “12/09/2024 9:00 AM”
  • With dash separator: “12/19/2024 - 2:00 PM”

Timezone Support

  • With timezone abbreviations: “10/23/2024 12:06 PM CST”
  • With timezone offset: “01/17/2025 3:00:00 PM CT”

Text Month Formats

  • Short month: “5 Dec 2024”, “11 Sep 2024”
  • With time: “5 Dec 2024 8:00 AM PST”
  • Full month: “November 14, 2024”, “January 31, 2025, 5:00 pm”

Examples

from intuned_browser import process_date
async def automation(page, params, **_kwargs):
    # Basic date string
    date1 = process_date("22/11/2024")
    print(date1)  # 2024-11-22 00:00:00

    # Date with time (time is ignored)
    date2 = process_date("5 Dec 2024 8:00 AM PST")
    print(date2)  # 2024-12-05 00:00:00

Arguments

date_string
str
required
A string containing a date in various possible formats

Returns: datetime | None

Returns a datetime object with:
  • Only date components preserved (year, month, day)
  • Time always set to 00:00:00
  • None if parsing fails