Ejemplo n.º 1
0
        // returns true if the start date is before or equal to the end date
        private bool IsStartBeforeEnd(DateValueNode start, DateValueNode end)
        {
            if (start.Year < end.Year)
            {
                return(true);
            }

            if (start.Year > end.Year)
            {
                return(false);
            }

            // must be the same start and end year if we get here

            if (start.Month < end.Month)
            {
                return(true);
            }

            if (start.Month > end.Month)
            {
                return(false);
            }

            // must be the same month

            return(start.Day <= end.Day);
        }
Ejemplo n.º 2
0
        private DateValueNode ParseDate()
        {
            var date = new DateValueNode();

            var tok = Expect(TokenType.PositiveInteger);

            date.AddToken(tok);
            var one = int.Parse(tok.Value);

            date.AddToken(Expect(TokenType.ForwardSlash));

            tok = Expect(TokenType.PositiveInteger);
            date.AddToken(tok);
            var two = int.Parse(tok.Value);

            int three = -1;

            if (IsNext(TokenType.ForwardSlash))
            {
                date.AddToken(Expect(TokenType.ForwardSlash));

                tok = Expect(TokenType.PositiveInteger);
                date.AddToken(tok);
                three = int.Parse(tok.Value);
            }

            if (three != -1)
            {
                // date has a year
                date.Year  = one;
                date.Month = two;
                date.Day   = three;
            }
            else
            {
                // no year
                date.Month = one;
                date.Day   = two;
            }

            return(date);
        }
Ejemplo n.º 3
0
        private DateValueNode ParseDate()
        {
            var date = new DateValueNode();

            var tok = Expect(TokenType.PositiveInteger);
            date.AddToken(tok);
            var one = int.Parse(tok.Value);

            date.AddToken(Expect(TokenType.ForwardSlash));

            tok = Expect(TokenType.PositiveInteger);
            date.AddToken(tok);
            var two = int.Parse(tok.Value);

            int three = -1;
            if (IsNext(TokenType.ForwardSlash))
            {
                date.AddToken(Expect(TokenType.ForwardSlash));

                tok = Expect(TokenType.PositiveInteger);
                date.AddToken(tok);
                three = int.Parse(tok.Value);
            }

            if (three != -1)
            {
                // date has a year
                date.Year = one;
                date.Month = two;
                date.Day = three;
            }
            else
            {
                // no year
                date.Month = one;
                date.Day = two;
            }

            return date;
        }
Ejemplo n.º 4
0
        // returns true if the start date is before or equal to the end date
        private bool IsStartBeforeEnd(DateValueNode start, DateValueNode end)
        {
            if (start.Year < end.Year)
                return true;

            if (start.Year > end.Year)
                return false;

            // must be the same start and end year if we get here

            if (start.Month < end.Month)
                return true;

            if (start.Month > end.Month)
                return false;

            // must be the same month

            return start.Day <= end.Day;
        }