pdt_locales
All of the included locale classes shipped with pdt.
Bases: cloudfusion.third_party.parsedatetime.parsedatetime.pdt_locales.pdtLocale_base
en_AU Locale
Bases: object
default values for Locales
Bases: cloudfusion.third_party.parsedatetime.parsedatetime.pdt_locales.pdtLocale_base
de_DE Locale constants
Contributed by Debian parsedatetime package maintainer Bernd Zeimetz <bzed@debian.org>
Bases: cloudfusion.third_party.parsedatetime.parsedatetime.pdt_locales.pdtLocale_base
en_US Locale
Bases: cloudfusion.third_party.parsedatetime.parsedatetime.pdt_locales.pdtLocale_base
es Locale
Note that I don’t speak Spanish so many of the items below are still in English
Bases: cloudfusion.third_party.parsedatetime.parsedatetime.pdt_locales.pdtLocale_base
Create a locale from pyICU
parsedatetime
Parse human-readable date/time text.
Requires Python 2.6 or later
A collection of routines to input, parse and manipulate date and times. The text can either be ‘normal’ date values or it can be human readable.
Default constructor for the L{Calendar} class.
@type constants: object @param constants: Instance of the class L{Constants}
@rtype: object @return: L{Calendar} instance
Based on the C{style} and C{currentDayStyle} determine what day-of-week value is to be returned.
@type wd: integer @param wd: day-of-week value for the current day @type wkdy: integer @param wkdy: day-of-week value for the parsed day @type offset: integer @param offset: offset direction for any modifiers (-1, 0, 1) @type style: integer @param style: normally the value set in C{Constants.DOWParseStyle} @type currentDayStyle: integer @param currentDayStyle: normally the value set in C{Constants.CurrentDOWParseStyle}
@rtype: integer @return: calculated day-of-week
Take C{quantity}, C{modifier} and C{unit} strings and convert them into values. After converting, calcuate the time and return the adjusted sourceTime.
@type source: time @param source: time to use as the base (or source) @type quantity: string @param quantity: quantity string @type modifier: string @param modifier: how quantity and units modify the source time @type units: string @param units: unit of the quantity (i.e. hours, days, months, etc)
@rtype: struct_time @return: C{struct_time} of the calculated time
Converts text units into their number value
Five = 5 Twenty Five = 25 Two hundred twenty five = 225 Two thousand and twenty five = 2025 Two thousand twenty five = 2025
@type unitText: string @param unitText: number text to convert
@rtype: integer @return: numerical value of unitText
Evaluate the C{modifier} string and following text (passed in as C{chunk1} and C{chunk2}) and if they match any known modifiers calculate the delta and apply it to C{sourceTime}.
@type modifier: string @param modifier: modifier text to apply to sourceTime @type chunk1: string @param chunk1: first text chunk that followed modifier (if any) @type chunk2: string @param chunk2: second text chunk that followed modifier (if any) @type sourceTime: struct_time @param sourceTime: C{struct_time} value to use as the base
@rtype: tuple @return: tuple of: remaining text and the modified sourceTime
Evaluate the C{modifier} string and following text (passed in as C{chunk1} and C{chunk2}) and if they match any known modifiers calculate the delta and apply it to C{sourceTime}.
@type modifier: string @param modifier: modifier text to apply to C{sourceTime} @type chunk1: string @param chunk1: first text chunk that followed modifier (if any) @type chunk2: string @param chunk2: second text chunk that followed modifier (if any) @type sourceTime: struct_time @param sourceTime: C{struct_time} value to use as the base
@rtype: tuple @return: tuple of: remaining text and the modified sourceTime
Calculate the datetime based on flags set by the L{parse()} routine
@type datetimeString: string @param datetimeString: text to try and parse as more “traditional”
date/time text
@type sourceTime: struct_time @param sourceTime: C{struct_time} value to use as the base
@rtype: datetime @return: calculated C{struct_time} value or current C{struct_time}
if not parsed
Convert a quantity, either spelled-out or numeric, to an integer
@type quantity: string @param quantity: quantity to parse to int @rtype: int @return: the quantity as an integer, defaulting to 0
Evaluate the C{datetimeString} text and determine if it represents a date or time range.
@type datetimeString: string @param datetimeString: datetime text to evaluate @type sourceTime: struct_time @param sourceTime: C{struct_time} value to use as the base
@rtype: tuple @return: tuple of: start datetime, end datetime and the invalid flag
Takes the given C{source} date, or current date if none is passed, and increments it according to the values passed in by month and/or year.
This routine is needed because Python’s C{timedelta()} function does not allow for month or year increments.
@type source: struct_time @param source: C{struct_time} value to increment @type month: integer @param month: optional number of months to increment @type year: integer @param year: optional number of years to increment
@rtype: datetime @return: C{source} incremented by the number of months and/or years
Utilizes parse() after making judgements about what datetime information belongs together.
It makes logical groupings based on proximity and returns a parsed datetime for each matched grouping of datetime text, along with location info within the given inputString.
@type inputString: string @param inputString: natural language text to evaluate @type sourceTime: struct_time @param sourceTime: C{struct_time} value to use as the base
@rtype: tuple or None @return: tuple of tuples in the format (parsed_datetime as datetime.datetime, flags as int, start_pos as int,
end_pos as int, matched_text as string) or None if there were no matches
Splits the given C{datetimeString} into tokens, finds the regex patterns that match and then calculates a C{struct_time} value from the chunks.
If C{sourceTime} is given then the C{struct_time} value will be calculated from that value, otherwise from the current date/time.
If the C{datetimeString} is parsed and date/time value found then the second item of the returned tuple will be a flag to let you know what kind of C{struct_time} value is being returned:
0 = not parsed at all
1 = parsed as a C{date}
2 = parsed as a C{time}
3 = parsed as a C{datetime}
@type datetimeString: string @param datetimeString: date/time text to evaluate @type sourceTime: struct_time @param sourceTime: C{struct_time} value to use as the base
@rtype: tuple @return: tuple of: modified C{sourceTime} and the result flag
Parse short-form date strings:
'05/28/2006' or '04.21'
@type dateString: string @param dateString: text to convert to a C{datetime}
@rtype: struct_time @return: calculated C{struct_time} value of dateString
Parse long-form date strings:
'May 31st, 2006'
'Jan 1st'
'July 2006'
@type dateString: string @param dateString: text to convert to a datetime
@rtype: struct_time @return: calculated C{struct_time} value of dateString
Bases: object
Default set of constants for parsedatetime.
If PyICU is present, then the class will first try to get PyICU to return a locale specified by C{localeID}. If either C{localeID} is None or if the locale does not exist within PyICU, then each of the locales defined in C{fallbackLocales} is tried in order.
If PyICU is not present or none of the specified locales can be used, then the class will initialize itself to the en_US locale.
if PyICU is not present or not requested, only the locales defined by C{pdtLocales} will be searched.
Return a dictionary of date/time tuples based on the keys found in self.re_sources.
The current time is used as the default and any specified item found in self.re_sources is inserted into the value and the generated dictionary is returned.
Take the given month (1-12) and a given year (4 digit) return the number of days in the month adjusting for leap year as needed
Initialize symbols and single character constants.
Parse an RFC822, RFC1123, RFC2822, or asctime-style date