예제 #1
0
        public static bool TryParse(string value, out FiscalYear fiscalYear)
        {
            fiscalYear = null;

            if (string.IsNullOrWhiteSpace(value))
            {
                return(false);
            }

            var fySplit = value.Split('/');

            if (fySplit.Length == 2)
            {
                if (int.TryParse(fySplit[0], out var startYear) && int.TryParse(fySplit[1], out var endYear) && startYear > 0 && startYear + 1 == endYear)
                {
                    fiscalYear = new FiscalYear(startYear);
                }
            }
            else if (fySplit.Length == 1)
            {
                if (int.TryParse(fySplit[0], out var startYear))
                {
                    fiscalYear = new FiscalYear(startYear);
                }
            }

            return(fiscalYear != null);
        }
예제 #2
0
        public static new bool Equals(object year1, object year2)
        {
            FiscalYear year1Obj = year1 as FiscalYear;
            FiscalYear year2Obj = year2 as FiscalYear;

            if (year1Obj is null && year2Obj is null)
            {
                return(true);
            }
            if (year1Obj is null ^ year2Obj is null)
            {
                return(false);
            }

            return(year1Obj.StartCalendarYear == year2Obj.StartCalendarYear);
        }