1. Brandon Nielsen
  2. aniso8601

Commits

Brandon Nielsen  committed a5f29f8

Initial commit of some files.

  • Participants
  • Branches master

Comments (0)

Files changed (2)

File aniso8601/__init__.py

View file
  • Ignore whitespace
+import datetime
+
+def parse_year(yearstr):
+    #yearstr is of the format YYYY
+    #
+    #0000 (0 BC) is not representible as a datetime so a ValueError is raised
+    #
+    #Since no additional resolution is provided, the month is set to 1, and
+    #day is set to 1.
+
+    return datetime.date(int(yearstr), 1, 1)

File aniso8601/test_aniso8601.py

View file
  • Ignore whitespace
+import unittest
+import aniso8601
+
+class TestParseFunctions(unittest.TestCase):
+    def test_parse_year(self):
+        date = aniso8601.parse_year('2013')
+        self.assertEqual(date.year, 2013)
+        self.assertEqual(date.month, 1)
+        self.assertEqual(date.day, 1)