Fixes #31 : Use RFC 3339 for datetimes

This commit is contained in:
Thomas Pelletier
2014-12-06 15:00:24 +01:00
parent 2f2f28631b
commit 4b47f52cb0
4 changed files with 40 additions and 6 deletions
+5 -4
View File
@@ -192,7 +192,10 @@ func (l *tomlLexer) lexRvalue() tomlLexStateFn {
return l.lexKey
}
if dateRegexp.FindString(l.input[l.pos:]) != "" {
dateMatch := dateRegexp.FindString(l.input[l.pos:])
if dateMatch != "" {
l.ignore()
l.pos += len(dateMatch)
return l.lexDate
}
@@ -214,8 +217,6 @@ func (l *tomlLexer) lexRvalue() tomlLexStateFn {
}
func (l *tomlLexer) lexDate() tomlLexStateFn {
l.ignore()
l.pos += 20 // Fixed size of a date in TOML
l.emit(tokenDate)
return l.lexRvalue
}
@@ -461,7 +462,7 @@ func (l *tomlLexer) lexNumber() tomlLexStateFn {
}
func init() {
dateRegexp = regexp.MustCompile("^\\d{1,4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z")
dateRegexp = regexp.MustCompile("^\\d{1,4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,9})?(Z|[+-]\\d{2}:\\d{2})")
}
// Entry point