protected override void VisitMakeDateFunctionToken(MakeDateFunctionToken token) { State.Write(MySqlSymbols.TIMESTAMP); State.AddToTheEnd(MySqlSymbols.OpenParenthesis); DateTime date = new DateTime((int)((Scalar)token.Year).Value, (int)((Scalar)token.Month).Value, (int)((Scalar)token.Day).Value); State.Write(MySqlSymbols.MAKEDATE); State.AddToTheEnd(Symbols.OpenParenthesis); State.Write(date.Year.ToString()); State.Write(Symbols.Comma); State.Write(date.DayOfYear.ToString()); State.Write(Symbols.CloseParenthesis); State.Write(Symbols.Comma); State.Write(MySqlSymbols.MAKETIME); State.AddToTheEnd(Symbols.OpenParenthesis); if (token.Hour != null) { VisitToken(token.Hour); } else { State.Write("0"); } State.Write(Symbols.Comma); if (token.Minute != null) { VisitToken(token.Minute); } else { State.Write("0"); } State.Write(Symbols.Comma); if (token.Second != null) { VisitToken(token.Second); } else { State.Write("0"); } State.Write(Symbols.CloseParenthesis); State.Write(Symbols.CloseParenthesis); }
protected override void VisitMakeDateFunctionToken(MakeDateFunctionToken token) { State.Write(PostgrSQLSymbols.TIMESTAMP); StringBuilder sb = new StringBuilder(Symbols.SingleQuote); sb.Append(((Scalar)token.Year).Value); sb.Append(Symbols.MinusVal); sb.Append(((Scalar)token.Day).Value); sb.Append(Symbols.MinusVal); sb.Append(((Scalar)token.Month).Value); sb.Append(Symbols.Space); if (token.Hour != null) { sb.Append(((Scalar)token.Hour).Value); } else { sb.Append(0); } sb.Append(Symbols.Colon); if (token.Minute != null) { sb.Append(((Scalar)token.Minute).Value); } else { sb.Append(0); } sb.Append(Symbols.Colon); if (token.Second != null) { sb.Append(((Scalar)token.Second).Value); } else { sb.Append(0); } sb.Append(Symbols.SingleQuote); State.Write(sb.ToString()); }
protected abstract void VisitMakeDateFunctionToken(MakeDateFunctionToken token);
protected override void VisitMakeDateFunctionToken(MakeDateFunctionToken token) { //datetime('YYYY-MM-DDTHH:MM:SS.SSS'); State.Write(SqliteSymbols.datetime); State.Write(Symbols.OpenParenthesis); //year WriteDateTimePart("04d", token.Year, "2000"); // - State.Write(SqliteSymbols.Concat); State.Write(Symbols.SingleQuote); State.Write(Symbols.MinusVal); State.Write(Symbols.SingleQuote); State.Write(SqliteSymbols.Concat); // month WriteDateTimePart("02d", token.Month, "01"); // - State.Write(SqliteSymbols.Concat); State.Write(Symbols.SingleQuote); State.Write(Symbols.MinusVal); State.Write(Symbols.SingleQuote); State.Write(SqliteSymbols.Concat); // day WriteDateTimePart("02d", token.Day, "01"); // time part State.Write(SqliteSymbols.Concat); State.Write(Symbols.SingleQuote); State.Write("T"); State.Write(Symbols.SingleQuote); State.Write(SqliteSymbols.Concat); // hour WriteDateTimePart("02d", token.Hour, "00"); // : State.Write(SqliteSymbols.Concat); State.Write(Symbols.SingleQuote); State.Write(Symbols.Colon); State.Write(Symbols.SingleQuote); State.Write(SqliteSymbols.Concat); // minute WriteDateTimePart("02d", token.Minute, "00"); // : State.Write(SqliteSymbols.Concat); State.Write(Symbols.SingleQuote); State.Write(Symbols.Colon); State.Write(Symbols.SingleQuote); State.Write(SqliteSymbols.Concat); // second WriteDateTimePart("02d", token.Second, "00"); // . State.Write(SqliteSymbols.Concat); State.Write(Symbols.SingleQuote); State.Write(SqliteSymbols.DotVal); State.Write(Symbols.SingleQuote); State.Write(SqliteSymbols.Concat); // ms WriteDateTimePart("03d", token.Millisecond, "000"); State.Write(Symbols.CloseParenthesis); }