Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support datetime format with dot separator #8

Merged
merged 1 commit into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions nfp.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,13 @@ func (ps *Parser) getTokens() Tokens {
ps.Offset++
continue
}
if ps.Token.TType == TokenTypeDateTimes && !strings.ContainsAny(NumCodeChars, ps.nextChar()) {
ps.Tokens.add(ps.Token.TValue, ps.Token.TType, ps.Token.Parts)
ps.Tokens.add(ps.currentChar(), TokenTypeLiteral, ps.Token.Parts)
ps.Token = Token{}
ps.Offset++
continue
}
if !ps.InString {
if ps.Token.TType != "" && strings.ContainsAny(NumCodeChars, ps.nextChar()) {
ps.Tokens.add(ps.Token.TValue, ps.Token.TType, ps.Token.Parts)
Expand Down
3 changes: 3 additions & 0 deletions nfp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ var testStrings [][]string = [][]string{
{`DD/MM/YY;@`, "[{Positive [{DD DateTimes []} {/ Literal []} {MM DateTimes []} {/ Literal []} {YY DateTimes []}]} {Text [{@ TextPlaceHolder []}]}]"},
{`DD/MM/YYYY`, "[{Positive [{DD DateTimes []} {/ Literal []} {MM DateTimes []} {/ Literal []} {YYYY DateTimes []}]}]"},
{`DD/MM/YYYY;@`, "[{Positive [{DD DateTimes []} {/ Literal []} {MM DateTimes []} {/ Literal []} {YYYY DateTimes []}]} {Text [{@ TextPlaceHolder []}]}]"},
{`DD.MM.YY;@`, "[{Positive [{DD DateTimes []} {. Literal []} {MM DateTimes []} {. Literal []} {YY DateTimes []}]} {Text [{@ TextPlaceHolder []}]}]"},
{`DD.MM.YYYY`, "[{Positive [{DD DateTimes []} {. Literal []} {MM DateTimes []} {. Literal []} {YYYY DateTimes []}]}]"},
{`DD.MM.YYYY;@`, "[{Positive [{DD DateTimes []} {. Literal []} {MM DateTimes []} {. Literal []} {YYYY DateTimes []}]} {Text [{@ TextPlaceHolder []}]}]"},
{`DDD`, "[{Positive [{DDD DateTimes []}]}]"},
{`DDDD`, "[{Positive [{DDDD DateTimes []}]}]"},
{`DDDD", "MMMM\ DD", "YYYY`, "[{Positive [{DDDD DateTimes []} {, Literal []} {MMMM DateTimes []} { Literal []} {DD DateTimes []} {, Literal []} {YYYY DateTimes []}]}]"},
Expand Down
Loading