protocol.ftp.ls.date Module

Date and time parsing

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

Set of AM day period strings.

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

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 = {'午後', '下午', 'pm', 'nachm', 'م', 'अपर', '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?(am|午前|a. m|午後|下午|pm|ص|nachm|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.