Skip to content

Commit

Permalink
Support datetime format with dot separator
Browse files Browse the repository at this point in the history
  • Loading branch information
nicomni committed Sep 17, 2023
1 parent dc951e3 commit 4797489
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
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

0 comments on commit 4797489

Please sign in to comment.