| |
-
- text2datetime(timeStr, now=None, monthBeforeDay=True)
- text2datetime - Convert a time string to a datetime.datetime object. This method supports all the types of time strings described in text2datetime.FORMAT_HELP_MSG
PUBLIC FUNCTION
@param timeStr <str> - String of time.
@param now <None/datetime.datetime> - Default None will use current time. Otherwise, calculate time relative to given datetime.
@param monthBeforeDay <bool> - If True, American time format will be used when applicable (month/day/year). If False, European time (day/month/year) will be used when applicable.
print ( text2datetime.FORMAT_HELP_MSG ) for information on the format of timeStr.
@return <datetime.datetime> - Datetime object representing parsed time.
applyFixedTimeComponent(datetimeObj, fixedTimeStr) - applyFixedTimeComponent - Update a datetime object, replacing the time portion with the given time string.
PUBLIC FUNCTION
Time string is at minimum hours and minutes, with optional seconds and optional AM/PM.
@param datetimeObj <datetime.datetime> - Datetime
@param fixedTimeStr <str> - Time String as hours:minutes or hours:minutes:seconds, with optional AM/PM suffix.
@return <datetime.datetime> - datetimeObj with time replaced.
- applyRelativeTimeComponents(datetimeObj, timeStr)
- applyRelativeTimeComponents - Apply the provided relative adjustments to the given datetime.datetime object.
PUBLIC FUNCTION
For more information on the supported relative components, see text2datetime.FORMAT_HELP_MSG
This method only supports relative time components (like +4mo +5d). For all possible time strings, use the text2datetime method.
@param datetimeObj <datetime.datetime> - The datetime which serves as the starting point. Use datetime.datetime.now() to calculate relative to current date and time.
@param timeStr <str> - A string of relative components (like +5d for plus five days, or -2h for minus two hours.) See text2datetime.FORMAT_HELP_MSG for details.
@return <datetime.datetime> - A datetime object representing the date and time derived after applying all the relative components to the provided datetime.
- applyTimeWords(datetimeObj, timeStr)
- applyTimeWords - Apply one of several words that describe a time delta to the given datetime object. Example, "tomorrow"
PUBLIC FUNCTION
This method supports only time words, for all possible time transformations, use the text2datetime method.
See text2datetime.FORMAT_HELP_MSG for all available words.
@param datetimeObj - <datetime.datetime> - The origin datetime object
@param timeStr <str> - One of several words that describe a relative delta, see text2datetime.FORMAT_HELP_MSG for all available words. Case insensitive.
@return - <datetime.datetime/None> - The transformed datetime.datetime object if a valid word was given, otherwise None if there was no match.
- getDatetimeFromAmericanTime(timeStr)
- getDatetimeFromAmericanTime - Convert a string from American format (month/day/year), with an optional time, to a datetime object.
PUBLIC FUNCTION - Specifically handles fixed date (and potentially time) formatted strings. For all possible time strings, use the text2datetime method.
@param timeStr <str> - A string representing time in American format (month/day/year). Can also be followed by time, either in
hours:minutes:seconds or hours:minutes. Uses a 24-hour clock unless "AM" or "PM" is provided at the end of timeStr. Year can be 2 or 4 digit.
This function is equivalent to getDatetimeFromDateStr(timeStr, monthBeforeDay=True)
@return <datetime.datetime> - A datetime object representing the converted time.
- getDatetimeFromDateStr(timeStr, monthBeforeDay)
- getDatetimeFromDateStr - Convert a string that contains a date (month/day/year or day/month/year), with an optional time, to a datetime object.
PUBLIC FUNCTION - Specifically handles fixed date (and potentially time) formatted strings. For all possible time strings, use the text2datetime method.
@param timeStr <str> - A string representing time containing a forward-slash separated date, optionally followed by time, either in
hours:minutes:seconds or hours:minutes. Uses a 24-hour clock unless "AM" or "PM" is provided at the end of timeStr. Year can be 2 or 4 digit.
@param monthBeforeDay <bool> - If True, date will be assumed month/day/year. If False, date will be assumed day/month/year.
@return <datetime.datetime> - A datetime object representing the converted time.
- getDatetimeFromEuropeanTime(timeStr)
- getDatetimeFromAmericanTime - Convert a string from European format (day/month/year), with an optional time, to a datetime object.
PUBLIC FUNCTION - Specifically handles fixed date (and potentially time) formatted strings. For all possible time strings, use the text2datetime method.
@param timeStr <str> - A string representing time in European format (day/month/year). Can also be followed by time, either in
hours:minutes:seconds or hours:minutes. Uses a 24-hour clock unless "AM" or "PM" is provided at the end of timeStr. Year can be 2 or 4 digit.
This function is equivalent to getDatetimeFromDateStr(timeStr, monthBeforeDay=False)
@return <datetime.datetime> - A datetime object representing the converted time.
|