Using DateParser.match

DateParser is the only way to implement fast dates parsing.

The instance of DateParser uses basic date patterns from qddate.consts and generates extended list of patterns. It helps to reduce number of comparisons of strings significantly. Right now no language selection implemented but it doesn’t slow down date parsing.

This class wraps around the core qddate functionality.

class qddate.DateParser(generate=True, patterns=[{'key': 'dt:date:date_1', 'name': 'Datetime string', 'pattern': {{W:(0-9){1,2} Suppress:('/')} W:(0-9){1,2} Suppress:('/')} W:(0-9){4}, 'length': {'min': 8, 'max': 10}, 'format': '%d/%m/%Y'}, {'key': 'dt:date:date_2', 'name': 'Datetime string', 'pattern': {{W:(0-9){1,2} Suppress:('.')} W:(0-9){1,2} Suppress:('.')} W:(0-9){4}, 'length': {'min': 8, 'max': 10}, 'format': '%d.%m.%Y'}, {'key': 'dt:date:date_3', 'name': 'Datetime string', 'pattern': {{W:(0-9){4} '/'} W:(0-9){1,2} '/'} W:(0-9){1,2}, 'length': {'min': 8, 'max': 10}, 'format': '%Y/%m/%d'}, {'key': 'dt:date:date_4', 'name': 'Datetime string', 'pattern': {{W:(0-9){1,2} Suppress:('.')} W:(0-9){1,2} Suppress:('.')} W:(0-9){2}, 'length': {'min': 6, 'max': 8}, 'format': '%d.%m.%y', 'yearshort': True}, {'key': 'dt:date:date_iso8601', 'name': 'ISO 8601 date', 'pattern': {{W:(0-9){1,2} Suppress:('-')} W:(0-9){1,2} Suppress:('-')} W:(0-9){4}, 'length': {'min': 8, 'max': 10}, 'format': '%d-%m-%Y'}, {'key': 'dt:date:date_iso8601_short', 'name': 'ISO 8601 date shorted', 'pattern': {{W:(0-9){1,2} Suppress:('-')} W:(0-9){1,2} Suppress:('-')} W:(0-9){2}, 'length': {'min': 6, 'max': 8}, 'format': '%d-%m-%Y', 'yearshort': True}, {'key': 'dt:date:date_8', 'name': 'Date with 2-digits year', 'pattern': {{W:(0-9){1,2} Suppress:('/')} W:(0-9){1,2} Suppress:('/')} W:(0-9){2}, 'length': {'min': 6, 'max': 8}, 'format': '%d/%m/%y', 'yearshort': True}, {'key': 'dt:date:date_9', 'name': 'Date as ISO', 'pattern': {{W:(0-9){4} Suppress:('-')} W:(0-9){1,2} Suppress:('-')} W:(0-9){1,2}, 'length': {'min': 6, 'max': 10}, 'format': '%Y-%m-%d'}, {'key': 'dt:date:date_10', 'name': 'Date as yyyy.mm.dd', 'pattern': {{W:(0-9){4} Suppress:('.')} W:(0-9){1,2} Suppress:('.')} W:(0-9){1,2}, 'length': {'min': 6, 'max': 10}, 'format': '%Y.%m.%d'}, {'key': 'dt:date:date_usa_1', 'name': 'Date with 2-digits year', 'pattern': {{W:(0-9){1,2} Suppress:('/')} W:(0-9){1,2} Suppress:('/')} W:(0-9){2}, 'length': {'min': 6, 'max': 8}, 'format': '%m/%d/%y', 'yearshort': True}, {'key': 'dt:date:date_usa', 'name': 'USA mm/dd/yyyy string', 'pattern': {{W:(0-9){1,2} Suppress:('/')} W:(0-9){1,2} Suppress:('/')} W:(0-9){4}, 'length': {'min': 8, 'max': 10}, 'format': '%m/%d/%Y'}, {'key': 'dt:date:date_eng1', 'name': 'Date with english month and possible dots', 'pattern': {{{W:(0-9){1,2} Suppress:(['.'])} January | February | March | April | May | June | July | August | September | October | November | December} Suppress:(['.'])} W:(0-9){4}, 'length': {'min': 10, 'max': 20}, 'format': '%d.%b.%Y'}, {'key': 'dt:date:date_eng1x', 'name': 'Date with english month and , ', 'pattern': {{W:(0-9){1,2} January | February | March | April | May | June | July | August | September | October | November | December} Suppress:([','])} W:(0-9){4}, 'length': {'min': 10, 'max': 20}, 'format': '%d.%b.%Y'}, {'key': 'dt:date:date_eng1_lc', 'name': 'Date with english month lowcase', 'pattern': {{{W:(0-9){1,2} Suppress:(['.'])} january | february | march | april | may | june | jule | august | september | october | november | december} Suppress:(['.'])} W:(0-9){4}, 'length': {'min': 10, 'max': 20}, 'format': '%d.%b.%Y'}, {'key': 'dt:date:date_eng1_short', 'name': 'Date with english month short', 'pattern': {{{W:(0-9){1,2} Suppress:(['.'])} jan | feb | mar | apr | may | jun | jul | aug | sep | oct | nov | dec} Suppress:(['.'])} W:(0-9){4}, 'length': {'min': 10, 'max': 10}, 'format': '%d.%b.%Y'}, {'key': 'dt:date:date_eng2', 'name': 'Date with english month 2', 'pattern': {{January | February | March | April | May | June | July | August | September | October | November | December W:(0-9){1,2}} Suppress:([','])} W:(0-9){4}, 'length': {'min': 10, 'max': 20}, 'format': '%b %d, %Y'}, {'key': 'dt:date:date_eng2_lc', 'name': 'Date with english month 2 lowcase', 'pattern': {{january | february | march | april | may | june | jule | august | september | october | november | december W:(0-9){1,2}} Suppress:([','])} W:(0-9){4}, 'length': {'min': 10, 'max': 20}, 'format': '%b %d, %Y'}, {'key': 'dt:date:date_eng2_short', 'name': 'Date with english month 2 short', 'pattern': {{jan | feb | mar | apr | may | jun | jul | aug | sep | oct | nov | dec W:(0-9){1,2}} Suppress:([','])} W:(0-9){4}, 'length': {'min': 10, 'max': 10}, 'format': '%b %d, %Y'}, {'key': 'dt:date:date_eng3', 'name': 'Date with english month full', 'pattern': {{january | february | march | april | may | june | jule | august | september | october | november | december W:(0-9){1,2}} Suppress:([','])} W:(0-9){4}, 'length': {'min': 10, 'max': 20}, 'format': '%b %d, %Y', 'filter': 2}, {'key': 'dt:date:date_eng4_short', 'name': 'Date with english month short with dash', 'pattern': {{{W:(0-9){1,2} Suppress:(['-'])} jan | feb | mar | apr | may | jun | jul | aug | sep | oct | nov | dec} Suppress:(['-'])} W:(0-9){2}, 'length': {'min': 10, 'max': 10}, 'format': '%d-%b-%y', 'yearshort': True}, {'key': 'dt:date:noyear_1', 'name': 'Datetime string without year', 'pattern': {W:(0-9){2} Suppress:('.')} W:(0-9){2}, 'length': {'min': 5, 'max': 5}, 'format': '%d.%m', 'noyear': True}, {'key': 'dt:date:date_4_point', 'name': 'Datetime string', 'pattern': {{{W:(0-9){1,2} Suppress:('.')} W:(0-9){1,2} Suppress:('.')} W:(0-9){2} Suppress:('.')}, 'length': {'min': 6, 'max': 9}, 'format': '%d.%m.%y', 'yearshort': True}, {'key': 'dt:date:weekday_eng', 'name': 'Date with english month and weekday', 'pattern': {{{Suppress:(Monday | Tuesday | Wednesday | Thursday | Friday | Satuday | Sunday) Suppress:([','])} W:(0-9){1,2} January | February | March | April | May | June | July | August | September | October | November | December} Suppress:([','])} W:(0-9){4}, 'length': {'min': 17, 'max': 27}, 'format': '%d %m %Y', 'filter': 1}, {'key': 'dt:date:weekday_eng_lc', 'name': 'Date with english month and weekday', 'pattern': {{{Suppress:(Monday | Tuesday | Wednesday | Thursday | Friday | Satuday | Sunday) Suppress:([','])} W:(0-9){1,2} january | february | march | april | may | june | jule | august | september | october | november | december} Suppress:([','])} W:(0-9){4}, 'length': {'min': 17, 'max': 27}, 'format': '%d %m %Y', 'filter': 1}, {'key': 'dt:date:weekday_eng_wshort', 'name': 'Date with english month and weekday', 'pattern': {{{Suppress:(mon | tue | wed | thu | fri | sat | sun) Suppress:([','])} W:(0-9){1,2} January | February | March | April | May | June | July | August | September | October | November | December} Suppress:([','])} W:(0-9){4}, 'length': {'min': 16, 'max': 27}, 'format': '%d %m %Y', 'filter': 1}, {'key': 'dt:date:weekday_eng_mshort_wshort', 'name': 'Date with short english month and short weekday', 'pattern': {{Suppress:(mon | tue | wed | thu | fri | sat | sun) W:(0-9){1,2}} jan | feb | mar | apr | may | jun | jul | aug | sep | oct | nov | dec} W:(0-9){4}, 'length': {'min': 15, 'max': 15}, 'format': '%d %m %Y', 'filter': 1}, {'key': 'dt:date:weekday_eng_iso', 'name': 'Date with english weekday and iso date', 'pattern': {Suppress:(Monday | Tuesday | Wednesday | Thursday | Friday | Satuday | Sunday) Suppress:([','])} {{W:(0-9){1,2} Suppress:('/')} W:(0-9){1,2} Suppress:('/')} W:(0-9){4}, 'length': {'min': 13, 'max': 25}, 'format': '%d/%m/%Y', 'filter': 1}, {'key': 'dt:date:weekday_short_eng_iso', 'name': 'Date with english short weekday and iso date', 'pattern': {Suppress:(mon | tue | wed | thu | fri | sat | sun) Suppress:([','])} {{W:(0-9){1,2} Suppress:('/')} W:(0-9){1,2} Suppress:('/')} W:(0-9){4}, 'length': {'min': 13, 'max': 18}, 'format': '%d/%m/%Y', 'filter': 1}, {'key': 'dt:date:date_5', 'name': 'Datetime string as ddmmyyyy', 'pattern': {W:(0-9){2} W:(0-9){2}} W:(0-9){4}, 'length': {'min': 8, 'max': 8}, 'format': '%d%m%Y'}, {'key': 'dt:date:date_6', 'name': 'Datetime string as yyyymmdd', 'pattern': {W:(0-9){4} W:(0-9){2}} W:(0-9){2}, 'length': {'min': 8, 'max': 8}, 'format': '%Y%m%d'}, {'key': 'dt:date:bg_base', 'name': 'Base bulgarian date with month name', 'pattern': {W:(0-9){1,2} Янyapи | Фeвpyapи | Мapт | Апpил | Май | Юни | Юли | Авгycт | Сeптeмвpи | Октoмвpи | Нoeмвpи | Дeкeмвpи} W:(0-9){4}, 'length': {'min': 11, 'max': 22}, 'format': '%d %m %Y', 'filter': 1}, {'key': 'dt:date:bg_base_lc', 'name': 'Base bulgarian date with month name and lowcase', 'pattern': {W:(0-9){1,2} янyapи | фeвpyapи | мapт | aпpил | май | юни | юли | aвгycт | ceптeмвpи | oктoмвpи | нoeмвpи | дeкeмвpи} W:(0-9){4}, 'length': {'min': 11, 'max': 22}, 'format': '%d %m %Y', 'filter': 1}, {'key': 'dt:date:de_base', 'name': 'Base german date with month name', 'pattern': {{W:(0-9){1,2} Suppress:(['.'])} Januar | Februar | März | April | Mai | Juni | Juli | August | September | Oktober | November | Dezember} W:(0-9){4}, 'length': {'min': 11, 'max': 22}, 'format': '%d %m %Y', 'filter': 1}, {'key': 'dt:date:de_base_lc', 'name': 'Base german date with month name and lowcase', 'pattern': {{W:(0-9){1,2} Suppress:(['.'])} januar | februar | märz | april | mai | juni | juli | august | september | oktober | november | dezember} W:(0-9){4}, 'length': {'min': 11, 'max': 22}, 'format': '%d %m %Y', 'filter': 1}, {'key': 'dt:date:es_base', 'name': 'Base spanish date with month name not article', 'pattern': {W:(0-9){1,2} Enero | Febrero | Marzo | Abril | Mayo | Junio | Julio | Agosto | Septiembre | Octubre | Noviembre | Diciembre} W:(0-9){4}, 'length': {'min': 11, 'max': 22}, 'format': '%d %m %Y', 'filter': 1}, {'key': 'dt:date:es_base_lc', 'name': 'Base spanish date with month name and lowcase, no article', 'pattern': {W:(0-9){1,2} enero | febrero | marzo | abril | mayo | junio | julio | agosto | septiembre | octubre | noviembre | diciembre} W:(0-9){4}, 'length': {'min': 11, 'max': 22}, 'format': '%d %m %Y', 'filter': 1}, {'key': 'dt:date:es_base_article', 'name': 'Base spanish date with month name and articles', 'pattern': {{{W:(0-9){1,2} Suppress:('DE')} Enero | Febrero | Marzo | Abril | Mayo | Junio | Julio | Agosto | Septiembre | Octubre | Noviembre | Diciembre} Suppress:('DE')} W:(0-9){4}, 'length': {'min': 11, 'max': 26}, 'format': '%d %m %Y', 'filter': 1}, {'key': 'dt:date:es_base_lc_article', 'name': 'Base spanish date with month name and articles and lowcase', 'pattern': {{{W:(0-9){1,2} Suppress:('DE')} enero | febrero | marzo | abril | mayo | junio | julio | agosto | septiembre | octubre | noviembre | diciembre} Suppress:('DE')} W:(0-9){4}, 'length': {'min': 11, 'max': 26}, 'format': '%d %m %Y', 'filter': 1}, {'key': 'dt:date:es_rare_1', 'name': 'Spanish date stars with month name', 'pattern': {{Enero | Febrero | Marzo | Abril | Mayo | Junio | Julio | Agosto | Septiembre | Octubre | Noviembre | Diciembre W:(0-9){1,2}} Suppress:(',')} W:(0-9){4}, 'length': {'min': 11, 'max': 25}, 'format': '%M %d %Y', 'filter': 1}, {'key': 'dt:date:es_rare_2', 'name': 'Spanish date stars with month name lowcase', 'pattern': {{enero | febrero | marzo | abril | mayo | junio | julio | agosto | septiembre | octubre | noviembre | diciembre W:(0-9){1,2}} Suppress:(',')} W:(0-9){4}, 'length': {'min': 11, 'max': 25}, 'format': '%M %d %Y', 'filter': 1}, {'key': 'dt:date:fr_base', 'name': 'Base french date with month name not archive', 'pattern': {W:(0-9){1,2} Janvier | Février | Mars | Avril | Mai | Juin | Juillet | Août | Septembre | Octobre | Novembre | Décembre} W:(0-9){4}, 'length': {'min': 11, 'max': 22}, 'format': '%d %m %Y', 'filter': 1}, {'key': 'dt:date:fr_base_lc', 'name': 'Base french date with month name and lowcase, no article', 'pattern': {W:(0-9){1,2} janvier | février | mars | avril | mai | juin | juillet | août | septembre | octobre | novembre | décembre} W:(0-9){4}, 'length': {'min': 11, 'max': 22}, 'format': '%d %m %Y', 'filter': 1}, {'key': 'dt:date:fr_base_article', 'name': 'Base french date with month name and articles', 'pattern': {{Suppress:('LE') W:(0-9){1,2}} Janvier | Février | Mars | Avril | Mai | Juin | Juillet | Août | Septembre | Octobre | Novembre | Décembre} W:(0-9){4}, 'length': {'min': 11, 'max': 22}, 'format': '%d %m %Y', 'filter': 1}, {'key': 'dt:date:fr_base_lc_article', 'name': 'Base french date with month name and articles and lowcase', 'pattern': {{Suppress:('LE') W:(0-9){1,2}} janvier | février | mars | avril | mai | juin | juillet | août | septembre | octobre | novembre | décembre} W:(0-9){4}, 'length': {'min': 11, 'max': 22}, 'format': '%d %m %Y', 'filter': 1}, {'key': 'dt:date:it_base', 'name': 'Base italian date with month name not article', 'pattern': {W:(0-9){1,2} Gennaio | Febbraio | Marzo | Aprile | Maggio | Giugno | Luglio | Agosto | Settembre | Ottobre | Novembre | Dicembre} W:(0-9){4}, 'length': {'min': 11, 'max': 22}, 'format': '%d %m %Y', 'filter': 1}, {'key': 'dt:date:it_base_lc', 'name': 'Base italian date with month name and lowcase, no article', 'pattern': {W:(0-9){1,2} gennaio | febbraio | marzo | aprile | maggio | giugno | luglio | agosto | settembre | ottobre | novembre | dicembre} W:(0-9){4}, 'length': {'min': 11, 'max': 22}, 'format': '%d %m %Y', 'filter': 1}, {'key': 'dt:date:it_base_article', 'name': 'Base italian date with month name and articles', 'pattern': {{{W:(0-9){1,2} Suppress:('DE')} Gennaio | Febbraio | Marzo | Aprile | Maggio | Giugno | Luglio | Agosto | Settembre | Ottobre | Novembre | Dicembre} Suppress:('DE')} W:(0-9){4}, 'length': {'min': 11, 'max': 26}, 'format': '%d %m %Y', 'filter': 1}, {'key': 'dt:date:it_base_lc_article', 'name': 'Base italian date with month name and articles and lowcase', 'pattern': {{{W:(0-9){1,2} Suppress:('DE')} gennaio | febbraio | marzo | aprile | maggio | giugno | luglio | agosto | settembre | ottobre | novembre | dicembre} Suppress:('DE')} W:(0-9){4}, 'length': {'min': 11, 'max': 26}, 'format': '%d %m %Y', 'filter': 1}, {'key': 'dt:date:it_rare_1', 'name': 'Italian date stars with month name', 'pattern': {{Gennaio | Febbraio | Marzo | Aprile | Maggio | Giugno | Luglio | Agosto | Settembre | Ottobre | Novembre | Dicembre W:(0-9){1,2}} Suppress:(',')} W:(0-9){4}, 'length': {'min': 11, 'max': 25}, 'format': '%M %d %Y', 'filter': 1}, {'key': 'dt:date:it_rare_2', 'name': 'Italian date stars with month name lowcase', 'pattern': {{gennaio | febbraio | marzo | aprile | maggio | giugno | luglio | agosto | settembre | ottobre | novembre | dicembre W:(0-9){1,2}} Suppress:(',')} W:(0-9){4}, 'length': {'min': 11, 'max': 25}, 'format': '%M %d %Y', 'filter': 1}, {'key': 'dt:date:pt_base', 'name': 'Base portugal date with month name not article', 'pattern': {W:(0-9){1,2} Janeiro | Fevereiro | Março | Abril | Maio | Junho | Julho | Agosto | Setembro | Outubro | Novembro | Dezembro} W:(0-9){4}, 'length': {'min': 11, 'max': 22}, 'format': '%d %m %Y', 'filter': 1}, {'key': 'dt:date:pt_base_lc', 'name': 'Base portugal date with month name and lowcase, no article', 'pattern': {W:(0-9){1,2} janeiro | fevereiro | março | abril | maio | junho | julho | agosto | setembro | outubro | novembro | dezembro} W:(0-9){4}, 'length': {'min': 11, 'max': 22}, 'format': '%d %m %Y', 'filter': 1}, {'key': 'dt:date:pt_base_article', 'name': 'Base portugal date with month name and articles', 'pattern': {{{W:(0-9){1,2} Suppress:('DE')} Janeiro | Fevereiro | Março | Abril | Maio | Junho | Julho | Agosto | Setembro | Outubro | Novembro | Dezembro} Suppress:('DE')} W:(0-9){4}, 'length': {'min': 11, 'max': 26}, 'format': '%d %m %Y', 'filter': 1}, {'key': 'dt:date:pt_base_lc_article', 'name': 'Base portugal date with month name and articles and lowcase', 'pattern': {{{W:(0-9){1,2} Suppress:('DE')} janeiro | fevereiro | março | abril | maio | junho | julho | agosto | setembro | outubro | novembro | dezembro} Suppress:('DE')} W:(0-9){4}, 'length': {'min': 11, 'max': 26}, 'format': '%d %m %Y', 'filter': 1}, {'key': 'dt:date:date_rus', 'name': 'Date with russian month', 'pattern': {{{W:(0-9){1,2} Suppress:([','])} Января | Февраля | Марта | Апреля | Мая | Июня | Июля | Августа | Сентября | Октября | Ноября | Декабря} Suppress:([','])} W:(0-9){4}, 'length': {'min': 11, 'max': 20}, 'format': '%d %m %Y', 'filter': 1}, {'key': 'dt:date:date_rus2', 'name': 'Date with russian month and year word', 'pattern': {{{{W:(0-9){1,2} Suppress:([','])} Января | Февраля | Марта | Апреля | Мая | Июня | Июля | Августа | Сентября | Октября | Ноября | Декабря} Suppress:([','])} W:(0-9){4} Suppress:([г. | года])}, 'length': {'min': 13, 'max': 20}, 'format': '%d %m %Y', 'filter': 1}, {'key': 'dt:date:date_rus3', 'name': 'Date with russian year', 'pattern': {{{W:(0-9){1,2} Suppress:('.')} W:(0-9){1,2} Suppress:('.')} W:(0-9){4} Suppress:(г. | года)}, 'length': {'min': 14, 'max': 20}, 'format': '%d.%m.%Y'}, {'key': 'dt:date:date_rus_lc1', 'name': 'Date with russian month', 'pattern': {{{W:(0-9){1,2} Suppress:([','])} января | февраля | марта | апреля | мая | июня | июля | августа | сентября | октября | ноября | декабря} Suppress:([','])} W:(0-9){4}, 'length': {'min': 10, 'max': 20}, 'format': '%d %m %Y', 'filter': 1}, {'key': 'dt:date:date_rus_lc2', 'name': 'Date with russian month with year word', 'pattern': {{{W:(0-9){1,2} Suppress:([','])} января | февраля | марта | апреля | мая | июня | июля | августа | сентября | октября | ноября | декабря} W:(0-9){4} Suppress:([г. | года])}, 'length': {'min': 13, 'max': 25}, 'format': '%d %m %Y', 'filter': 1}, {'key': 'dt:date:weekday_rus', 'name': 'Date with russian month and weekday', 'pattern': {{{{Понедельник | Вторник | Среда | Четверг | Пятница | Суббота | Воскресение [',']} W:(0-9){1,2} Января | Февраля | Марта | Апреля | Мая | Июня | Июля | Августа | Сентября | Октября | Ноября | Декабря} Suppress:([','])} W:(0-9){4} Suppress:(г. | года)}, 'length': {'min': 13, 'max': 20}, 'format': '%d %m %Y', 'filter': 1}, {'key': 'dt:date:weekday_rus_lc1', 'name': 'Date with russian month and weekday', 'pattern': {{{{Понедельник | Вторник | Среда | Четверг | Пятница | Суббота | Воскресение [',']} W:(0-9){1,2} января | февраля | марта | апреля | мая | июня | июля | августа | сентября | октября | ноября | декабря} Suppress:([','])} W:(0-9){4} Suppress:(г. | года)}, 'length': {'min': 13, 'max': 25}, 'format': '%d %m %Y', 'filter': 1}, {'key': 'dt:date:rus_rare_2', 'name': 'Date with russian month with dots as divider', 'pattern': {{{W:(0-9){1,2} Suppress:(['.'])} Января | Февраля | Марта | Апреля | Мая | Июня | Июля | Августа | Сентября | Октября | Ноября | Декабря} Suppress:(['.'])} W:(0-9){4}, 'length': {'min': 11, 'max': 20}, 'format': '%d.%m.%Y', 'filter': 1}, {'key': 'dt:date:rus_rare_3', 'name': 'Date with russian month with dots as divider with low case months', 'pattern': {{{W:(0-9){1,2} Suppress:('.')} января | февраля | марта | апреля | мая | июня | июля | августа | сентября | октября | ноября | декабря} Suppress:('.')} W:(0-9){4}, 'length': {'min': 11, 'max': 20}, 'format': '%d.%m.%Y', 'filter': 1}, {'key': 'dt:date:rus_rare_5', 'name': 'Russian date stars with month name', 'pattern': {{Январь | Февраль | Март | Апрель | Май | Июнь | Июль | Август | Сентябрь | Октябрь | Ноябрь | Декабрь W:(0-9){1,2}} Suppress:(',')} W:(0-9){4}, 'length': {'min': 13, 'max': 22}, 'format': '%d %m %Y', 'filter': 1}, {'key': 'dt:date:rus_rare_6', 'name': 'Russian date stars with weekday and follows with month name', 'pattern': {{{Suppress:(понедельник | вторник | среда | четверг | пятница | суббота | воскресение) Suppress:(',')} января | февраля | марта | апреля | мая | июня | июля | августа | сентября | октября | ноября | декабря} W:(0-9){1,2} Suppress:(',')} W:(0-9){4}, 'length': {'min': 13, 'max': 22}, 'format': '%d %m %Y', 'filter': 1}], base_only=False)[source]

Class to use pyparsing-based patterns to parse dates

match(text, noprefix=False, noyear=True)[source]

Matches date/datetime string against date patterns and returns pattern and parsed date if matched. It’s not indeded for common usage, since if successful it returns date as array of numbers and pattern that matched this date

Parameters:
  • text – Any human readable string
  • noprefix (bool) – If set True than doesn’t use prefix based date patterns filtering settings
  • noyear – If set True than does use patterns with noyear flag (does a lot of false positives) if set False doesn’t use patterns with noyear flag
Returns:

Returns dicts with values as array of representing parsed date and ‘pattern’ with info about matched pattern if successful, else returns None

Return type:

dict.

Warning

It returns raw matched date and raw pattern:

>>> dp.match('11 August 2017')
{'values': (['11', 8, '2017'], {'day': ['11'], 'month': [8], 'year': ['2017']}), 'pattern': {'key': 'dt:date:date_eng1', 'name': 'Date with english month', 'pattern': {W:(0123...) Suppress:(["."]) January | February | March | April | May | June | July | August | September | October | November | December Suppress:(["."]) W:(0123...)}, 'length': {'min': 10, 'max': 20}, 'format': '%d.%b.%Y', 'right': True, 'basekey': 'dt:date:date_eng1'}}