protocol.ftp.ls.date Module

Date and time parsing

wpull.protocol.ftp.ls.date.AM_STRINGS = {'a. m', '午前', 'am', '上午', 'ص', 'पूर्व', 'vorm'}

Set of AM day period strings.

wpull.protocol.ftp.ls.date.DAY_PERIOD_PATTERN = re.compile('(a. m|午前|下午|nachm|am|上午|pm|अपर|午後|ص|पूर्व|م|vorm|p. m)\\b', re.IGNORECASE)

Regex pattern for AM/PM string.

wpull.protocol.ftp.ls.date.ISO_8601_DATE_PATTERN = re.compile('(\\d{4})(?!\\d)[\\w./-](\\d{1,2})(?!\\d)[\\w./-](\\d{1,2})')

Regex pattern for dates similar to YYYY-MM-DD.

wpull.protocol.ftp.ls.date.MMM_DD_YY_PATTERN = re.compile('([^\\W\\d_]{3,4})\\s{0,4}(\\d{1,2})\\s{0,4}(\\d{0,4})')

Regex pattern for dates similar to MMM DD YY.

Example: Feb 09 90

wpull.protocol.ftp.ls.date.MONTH_MAP = {'janv': 1, 'märz': 3, 'fev': 2, 'jan': 1, 'ديسمبر': 12, '1月': 1, 'ago': 8, 'мая': 5, 'feb': 2, 'अक्टू': 10, 'mars': 3, 'févr': 2, 'dic': 12, 'нояб': 11, 'दिसं': 12, '2月': 2, '8月': 8, 'juni': 6, 'مايو': 5, 'juli': 7, 'abr': 4, 'янв': 1, 'मई': 5, 'maj': 5, 'окт': 10, 'lut': 2, 'سبتمبر': 9, 'जुला': 7, 'apr': 4, 'dez': 12, 'set': 9, 'يناير': 1, 'أغسطس': 8, 'أبريل': 4, 'अग': 8, 'sept': 9, '6月': 6, 'sie': 8, '4月': 4, 'апр': 4, 'mai': 5, 'lis': 11, 'नवं': 11, 'lip': 7, 'дек': 12, 'juin': 6, 'सितं': 9, 'avr': 4, 'मार्च': 3, '12月': 12, 'août': 8, 'نوفمبر': 11, 'марта': 3, 'cze': 6, 'dec': 12, 'juil': 7, 'okt': 10, 'أكتوبر': 10, 'nov': 11, 'مارس': 3, 'जन': 1, 'ene': 1, 'sep': 9, 'jun': 6, 'sty': 1, 'फ़र': 2, 'aug': 8, 'февр': 2, 'oct': 10, '7月': 7, 'يوليو': 7, 'gru': 12, 'kwi': 4, '9月': 9, 'paź': 10, 'jul': 7, 'فبراير': 2, 'июня': 6, 'wrz': 9, '3月': 3, 'يونيو': 6, 'out': 10, 'जून': 6, 'авг': 8, 'may': 5, '10月': 10, 'mar': 3, 'अप्रै': 4, 'сент': 9, '11月': 11, 'июля': 7, 'déc': 12, '5月': 5}

Month names to int.

wpull.protocol.ftp.ls.date.NN_NN_NNNN_PATTERN = re.compile('(\\d{1,2})[./-](\\d{1,2})[./-](\\d{2,4})')

Regex pattern for dates similar to NN NN YYYY.

Example: 2/9/90

wpull.protocol.ftp.ls.date.PM_STRINGS = {'下午', 'nachm', 'pm', 'अपर', '午後', 'م', 'p. m'}

Set of PM day period strings.

wpull.protocol.ftp.ls.date.TIME_PATTERN = re.compile('(\\d{1,2}):(\\d{2}):?(\\d{0,2})\\s?(a. m|午前|下午|nachm|am|上午|pm|अपर|午後|ص|पूर्व|م|vorm|p. m|\x08)?')

Regex pattern for time in HH:MM[:SS]

wpull.protocol.ftp.ls.date.guess_datetime_format(lines: typing.Iterable, threshold: int=5) → typing.Tuple[source]

Guess whether order of the year, month, day and 12/24 hour.

Returns:First item is either str ymd, dmy, mdy or None. Second item is either True for 12-hour time or False for 24-hour time or None.
Return type:tuple
wpull.protocol.ftp.ls.date.parse_cldr_json(directory, language_codes=('zh', 'es', 'en', 'hi', 'ar', 'pt', 'ru', 'ja', 'de', 'fr', 'pl'), massage=True)[source]

Parse CLDR JSON datasets to for date time things.

wpull.protocol.ftp.ls.date.parse_datetime(text: str, date_format: str=None, is_day_period: typing.Union=None, datetime_now: datetime.datetime=None) → typing.Tuple[source]

Parse date/time from a line of text into datetime object.

wpull.protocol.ftp.ls.date.parse_month(text: str) → int[source]

Parse month string into integer.

wpull.protocol.ftp.ls.date.y2k(year: int) → int[source]

Convert two digit year to four digit year.