]> git.parisson.com Git - telemeta-data.git/commitdiff
migration: refuse to parse years that consist in 1 or 3 digits
authorolivier <olivier@3bf09e05-f825-4182-b9bc-eedd7160adf0>
Thu, 11 Jun 2009 17:12:22 +0000 (17:12 +0000)
committerolivier <olivier@3bf09e05-f825-4182-b9bc-eedd7160adf0>
Thu, 11 Jun 2009 17:12:22 +0000 (17:12 +0000)
git-svn-id: http://svn.parisson.org/svn/crem@101 3bf09e05-f825-4182-b9bc-eedd7160adf0

trunk/import/migration/tasks/core.py

index e26b7435e55268fb01d77155a546e0ec01a901d5..60bb15a80f7289567aabb6f09cb19ec9cb3a8a46 100644 (file)
@@ -61,14 +61,16 @@ class DataMigrator(DataMigrationTask):
 
         return assign
 
-    def parse_year(self, year):
-        if year < 100 and year > 0:
-            if year <= date.today().year % 100:
-                return year + 2000
-            else:
-                return year + 1900
-        elif year >= 1900 and year <= date.today().year:
-            return year
+    def parse_year(self, year_str):
+        if len(year_str) == 2 or len(year_str) == 4:
+            year = int(year_str)
+            if year < 100 and year > 0:
+                if year <= date.today().year % 100:
+                    return year + 2000
+                else:
+                    return year + 1900
+            elif year >= 1900 and year <= date.today().year:
+                return year
 
         return 0