CAT-SOOP API: catsoop.time

Utilities for dealing with time

View Source

Members

  • catsoop.time.days (list)

    List used for mapping weekday numbers to weekday letters

 

  • catsoop.time.detailed_timestamp (function, lines 136-147)

    Generate a detailed timestamp. (e.g. "2013-06-05:14:58:21.024717")

    Parameters:

    • time: an instance of datetime.datetime

    Returns: a string containing a representation of the given time

 

  • catsoop.time.from_detailed_timestamp (function, lines 150-161)

    Generate an instance of datetime from a detailed timestamp.

    Parameters:

    • time: a string of the same form as the output from catsoop.time.detailed_timestamp

    Returns: a datetime.datetime instance representing the given time

 

  • catsoop.time.long_timestamp (function, lines 106-118)

    Generate a (long) human-readable timestamp (e.g., "Wednesday June 05, 2013; 02:58:21 PM")

    Parameters:

    • time: an instance of datetime.datetime

    Returns: a string containing a human-readable representation of the given time

 

  • catsoop.time.now (function, lines 97-103)

    Wraps datetime.now.

    Returns: the current time, as an instance of datetime.datetime

 

  • catsoop.time.realize_time (function, lines 27-81)

    Return an appropriate datetime.datetime object based on the given timestring.

    The timestring can have one of the following forms:

    • 'NEVER': resolves to the maximum date that datetime can represent
    • 'ALWAYS': resolves to the minimum date that `datetime can represent
    • 'YYYY-MM-DD:HH:MM' resolves to a particular time (minute resolution)
    • 'W:HH:MM, where W is a letter representing a day of the week, resolves to the given time in the week number given by cs_week_number, starting from cs_first_monday. For example, 'T:09:00' represents Tuesday morning at 9 o'clock.

    Parameters:

    • context: the context associated with this request (from which cs_first_monday and cs_week_number are read)
    • timestring: a string representing the desired time (see above)

    Returns: a datetime.datetime object corresponding to the time given by timestring

 

  • catsoop.time.short_timestamp (function, lines 121-133)

    Generate a (short) human-readable timestamp (e.g. "Jun 05, 2013; 02:58 PM")

    Parameters:

    • time: an instance of datetime.datetime

    Returns: a string containing a human-readable representation of the given time

 

  • catsoop.time.unix (function, lines 84-94)

    Generate a Unix timestamp from an instance of datetime.

    Parameters:

    • dt: an instance of datetime.datetime

    Returns: the Unix timestamp corresponding to the given time