Source

pyorg / pyorg / parser.py

Diff from to

File pyorg/parser.py

 """Parser related stuff
 """
 import re
-
+from datetime import date
 def maxhead(text):
     """tell which is the topmost level, if there isn't one, return None
     """
     regex = re.compile("^\s*:(\w+):\s*(.*?)\s*$",re.MULTILINE)
     return dict(regex.findall(props))
 
-
+def parse_date(datestr):
+    """parse a typical date formatted in the org mode style
+    """
+    regex = re.compile("<(\d{4})-(\d{2})-(\d{2}) .*?>")
+    match = regex.search(datestr)
+    if match:
+        y,m,d = [int(it) for it in match.groups()]
+        return date(y,m,d)
+        
 class Node(object):
     """represent a typical headline+text in an orgnode file
     """