Skip to content

Latest commit

 

History

History
101 lines (55 loc) · 4.83 KB

File metadata and controls

101 lines (55 loc) · 4.83 KB
graph LR
    naturaltime["naturaltime"]
    naturaldate["naturaldate"]
    precisedelta["precisedelta"]
    naturaldelta["naturaldelta"]
    naturalday["naturalday"]
    _date_and_delta["_date_and_delta"]
    _abs_timedelta["_abs_timedelta"]
    _now["_now"]
    naturaltime -- "uses" --> naturaldelta
    naturaltime -- "uses" --> _date_and_delta
    naturaldate -- "uses" --> naturalday
    naturaldate -- "uses" --> _abs_timedelta
    precisedelta -- "uses" --> _date_and_delta
    _date_and_delta -- "uses" --> _abs_timedelta
    _date_and_delta -- "uses" --> _now
    _abs_timedelta -- "uses" --> _now
Loading

CodeBoardingDemoContact

Details

The Time Humanization Module is a core component of the humanize utility library, specifically designed to convert date and time objects into human-readable formats. It adheres to the project's architectural bias of organizing components by the type of data they humanize, with all its functionalities encapsulated within src/humanize/time.py.

naturaltime

The main entry point for converting datetime or timedelta objects into human-readable relative time strings (e.g., "2 days ago", "in 3 hours"). It orchestrates the process of calculating time differences and formatting the output.

Related Classes/Methods:

naturaldate

The primary function for transforming date objects into human-readable relative date strings (e.g., "today", "yesterday", "on Jan 1st"). It focuses on date-specific humanization, often ignoring time components.

Related Classes/Methods:

precisedelta

Provides a highly precise, multi-unit human-readable representation of a timedelta object (e.g., "1 year, 2 months, 3 days"). This component is used when a more detailed breakdown of a time duration is required.

Related Classes/Methods:

naturaldelta

A specialized helper function primarily used by naturaltime to format timedelta objects into concise human-readable strings. It handles the specific logic for rendering time differences in a natural language format.

Related Classes/Methods:

naturalday

A specialized helper function used by naturaldate to format date objects into concise human-readable day strings (e.g., "today", "yesterday"). It abstracts the logic for day-specific relative date calculations.

Related Classes/Methods:

_date_and_delta

A foundational utility responsible for processing various input date/time objects and calculating the relevant timedelta for humanization. It acts as a central pre-processor for time difference calculations.

Related Classes/Methods:

_abs_timedelta

A utility helper that calculates the absolute timedelta between two points in time, often used for comparisons where the direction of time difference is not relevant.

Related Classes/Methods:

_now

A utility helper that provides the current datetime object, serving as a consistent reference point for all relative time calculations within the module. This ensures uniformity in "now" references.

Related Classes/Methods: