From db770c8678bfd7922d3eecc640481bb08f4141f9 Mon Sep 17 00:00:00 2001 From: Adam Kariv Date: Wed, 13 Mar 2024 00:32:42 +0200 Subject: [PATCH] v1.20.6 Improve date inferring --- tableschema/VERSION | 2 +- tableschema/schema.py | 2 +- tests/test_schema.py | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tableschema/VERSION b/tableschema/VERSION index ae45fe8..7ad3277 100644 --- a/tableschema/VERSION +++ b/tableschema/VERSION @@ -1 +1 @@ -1.20.5 \ No newline at end of file +1.20.6 \ No newline at end of file diff --git a/tableschema/schema.py b/tableschema/schema.py index 33f6bdb..c079852 100644 --- a/tableschema/schema.py +++ b/tableschema/schema.py @@ -550,7 +550,7 @@ def __hash__(self): 'array', 'datetime', 'time', - ('date', ('%Y-%m-%d', '%Y/%m/%d', '%d/%m/%Y', '%m/%d/%Y', '%Y%m%d', '%Y.%m.%d')), + ('date', ('%Y-%m-%d', '%Y/%m/%d', '%d/%m/%Y', '%m/%d/%Y', '%Y%m%d', '%Y.%m.%d', '%y-%m-%d', '%y/%m/%d', '%d/%m/%y', '%m/%d/%y', '%y%m%d', '%y.%m.%d')), 'integer', 'number', 'boolean', diff --git a/tests/test_schema.py b/tests/test_schema.py index 7139eda..5a65b32 100644 --- a/tests/test_schema.py +++ b/tests/test_schema.py @@ -310,10 +310,10 @@ def test_save(tmpdir, apply_defaults): def test_infer(): data = [ ['id', 'age', 'name', 'dob'], - ['1','39','Paul','28/1/1979'], - ['2','23','Jimmy','13/6/1995'], - ['3','36','Jane','17/9/1980'], - ['4','N/A','Judy','19/4/1983'], + ['1','39','Paul','28/1/79'], + ['2','23','Jimmy','13/6/95'], + ['3','36','Jane','17/9/80'], + ['4','N/A','Judy','19/4/83'], ] schema = Schema() schema.infer(data) @@ -322,7 +322,7 @@ def test_infer(): {'format': 'default', 'name': 'id', 'type': 'integer'}, {'format': 'default', 'name': 'age', 'type': 'integer'}, {'format': 'default', 'name': 'name', 'type': 'string'}, - {'format': '%d/%m/%Y', 'name': 'dob', 'type': 'date'}, + {'format': '%d/%m/%y', 'name': 'dob', 'type': 'date'}, ], 'missingValues': ['']} data = [