defmodule VinDecode.Dictionaries.Years do @moduledoc false @data_from1981to2009 %{ "B" => 1981, "C" => 1982, "D" => 1983, "E" => 1984, "F" => 1985, "G" => 1986, "H" => 1987, "J" => 1988, "K" => 1989, "L" => 1990, "M" => 1991, "N" => 1992, "P" => 1993, "R" => 1994, "S" => 1995, "T" => 1996, "V" => 1997, "W" => 1998, "X" => 1999, "Y" => 2000, "1" => 2001, "2" => 2002, "3" => 2003, "4" => 2004, "5" => 2005, "6" => 2006, "7" => 2007, "8" => 2008, "9" => 2009 } @data_from2010to2039 %{ "A" => 2010, "B" => 2011, "C" => 2012, "D" => 2013, "E" => 2014, "F" => 2015, "G" => 2016, "H" => 2017, "J" => 2018, "K" => 2019, "L" => 2020, "M" => 2021, "N" => 2022, "P" => 2023, "R" => 2024, "S" => 2025, "T" => 2026, "V" => 2027, "W" => 2028, "X" => 2029, "Y" => 2030, "1" => 2031, "2" => 2032 } def year(vin) do char7 = String.at(vin, 6) char10 = String.at(vin, 9) case Integer.parse(char7) do :error -> @data_from2010to2039[char10] {_number, _binary} -> @data_from1981to2009[char10] end end end