From c6ec50ccdfbdb48adf68282463f673150283c560 Mon Sep 17 00:00:00 2001 From: James Laska Date: Mon, 29 Aug 2011 08:00:18 -0400 Subject: Detect the older time and adjust start/end date appropriately --- get-mediawiki-data | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/get-mediawiki-data b/get-mediawiki-data index da80642..a525206 100755 --- a/get-mediawiki-data +++ b/get-mediawiki-data @@ -167,6 +167,18 @@ def list_usercontribs(wiki, user, date_start='', date_end='', namespaces=""): query['ucend'] = date_end if namespaces != '': query['ucnamespace'] = namespaces + if date_start != '' and date_end != '': + # if we can recognize the date format, see if we need to add ucdir + try: + date_start = re.sub('[TZ]', ' ', date_start).strip() + date_end = re.sub('[TZ]', ' ', date_end).strip() + ds = datetime.datetime.strptime(date_start, '%Y-%m-%d %H:%M:%S') + de = datetime.datetime.strptime(date_end, '%Y-%m-%d %H:%M:%S') + if ds < de: + query['ucdir'] = 'newer' + except ValueError: + pass + if opts.debug: print query response = wiki.call(query) -- cgit