Exemple #1
0
        static int GetYearFrom4charOr9charString(string s, FirstLastYear f)
        {
            // Two possible input formats:
            // A range of years: 1600-1700: Take term #p
            // Just a year: 1600: Take this year
            try
            {
                if (s.Contains('-'))
                {
                    string[] terms = s.Split('-');

                    if (f == FirstLastYear.First)
                    {
                        return(int.Parse(terms[0]));
                    }
                    else if (f == FirstLastYear.Last)
                    {
                        return(int.Parse(terms[1]));
                    }
                    else
                    {
                        throw new System.Exception("Cannot retrieve a year from the string " + s + " check file " + climateFileName);
                    }
                }
                else
                {
                    return(int.Parse(s));
                }
            }
            catch
            {
                throw new System.Exception("Cannot retrieve a year from the string " + s + " check file " + climateFileName);
            }
        }
        static int GetYearFrom4charOr9charString(string s, FirstLastYear f)
        {
            // Two possible input formats:
            // A range of years: 1600-1700: Take term #p
            // Just a year: 1600: Take this year
            try
            {
                if (s.Contains('-'))
                {
                    string[] terms = s.Split('-');

                    if (f == FirstLastYear.First) return int.Parse(terms[0]);
                    else if (f == FirstLastYear.Last)return int.Parse(terms[1]);
                    else throw new System.Exception("Cannot retrieve a year from the string " + s + " check file " + parameters.climateFileName);
                }
                else
                {
                    return int.Parse(s);
                }
            }
            catch
            {
                throw new System.Exception("Cannot retrieve a year from the string " + s + " check file " + parameters.climateFileName);
            }
        }