/// <summary> /// Visit a parse tree produced by <see cref="DateCalculatorParser.datetime"/>. /// <para> /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/> /// on <paramref name="context"/>. /// </para> /// </summary> /// <param name="context">The parse tree.</param> /// <return>The visitor result.</return> public virtual Result VisitDatetime([NotNull] DateCalculatorParser.DatetimeContext context) { return(VisitChildren(context)); }
/// <summary> /// Exit a parse tree produced by <see cref="DateCalculatorParser.datetime"/>. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="context">The parse tree.</param> public virtual void ExitDatetime([NotNull] DateCalculatorParser.DatetimeContext context) { }
/// <summary> /// Odpowiada za odwiedzenia węzła z typem Datetime i zwrócenie jego wartości /// </summary> /// <param name="context"></param> /// <returns></returns> public override Time VisitDatetime([NotNull] DateCalculatorParser.DatetimeContext context) { DateCalculatorParser.DateContext date = context.date(); DateCalculatorParser.DzienContext dzien = date.dzien(); DateCalculatorParser.MiesiacContext miesiac = date.miesiac(); DateCalculatorParser.RokContext rok = date.rok(); DateCalculatorParser.GodzinyContext godzina = context.godziny(); DateCalculatorParser.MinutyContext minuta = context.minuty(); DateCalculatorParser.SekundyContext sekunda = context.sekundy(); int miesiac_int = 0; switch (miesiac.GetText()) { case "STY": miesiac_int = 1; break; case "LUT": miesiac_int = 2; break; case "MAR": miesiac_int = 3; break; case "KWI": miesiac_int = 4; break; case "MAJ": miesiac_int = 5; break; case "CZE": miesiac_int = 6; break; case "LIP": miesiac_int = 7; break; case "SIE": miesiac_int = 8; break; case "WRZ": miesiac_int = 9; break; case "PAZ": miesiac_int = 10; break; case "LIS": miesiac_int = 11; break; case "GRU": miesiac_int = 12; break; default: break; } DateTime Data = new System.DateTime( Convert.ToInt32(rok.GetText()), miesiac_int, Convert.ToInt32(dzien.GetText()), Convert.ToInt32(godzina.GetText()), Convert.ToInt32(minuta.GetText()), Convert.ToInt32(sekunda.GetText()) ); Time wynik = new Time(); wynik.datetime = Data; wynik.isTimeSpan = false; return(wynik); }