You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rename encode_datetime_as to parse_datetime_as, add some unit tests, fix seconds missing in datetime tables (#16)
## Changes
- renamed `encode_datetime_as` to `parse_datetime_as`. I feel like it
makes more sense in the parser
- Added some unit tests around datetime parsing and max_nesting_depth
- fix bug with seconds not showing up in datetimes when parsed as tables
@@ -1162,7 +1163,7 @@ function tinytoml.parse(filename, options)
1162
1163
max_nesting_depth=1000,
1163
1164
max_filesize=100000000,
1164
1165
load_from_string=false,
1165
-
encode_datetime_as="string",
1166
+
parse_datetime_as="string",
1166
1167
type_conversion= {
1167
1168
["datetime"] =generic_type_conversion,
1168
1169
["datetime-local"] =generic_type_conversion,
@@ -1185,8 +1186,8 @@ function tinytoml.parse(filename, options)
1185
1186
assert(type(options.load_from_string) =="boolean", "the tinytoml option 'load_from_string' takes in a 'function'. You passed in the value '" ..tostring(options.load_from_string) .."' of type '" ..type(options.load_from_string) .."'")
1186
1187
end
1187
1188
1188
-
ifoptions.encode_datetime_as~=nilthen
1189
-
assert(type(options.encode_datetime_as) =="string", "the tinytoml option 'encode_datetime_as' takes in either the 'string' or 'table' (as type 'string'). You passed in the value '" ..tostring(options.encode_datetime_as) .."' of type '" ..type(options.encode_datetime_as) .."'")
1189
+
ifoptions.parse_datetime_as~=nilthen
1190
+
assert(type(options.parse_datetime_as) =="string", "the tinytoml option 'parse_datetime_as' takes in either the 'string' or 'table' (as type 'string'). You passed in the value '" ..tostring(options.parse_datetime_as) .."' of type '" ..type(options.parse_datetime_as) .."'")
1190
1191
end
1191
1192
1192
1193
ifoptions.type_conversion~=nilthen
@@ -1204,7 +1205,7 @@ function tinytoml.parse(filename, options)
@@ -1162,7 +1163,7 @@ function tinytoml.parse(filename: string, options?: TinyTomlOptions): {string:an
1162
1163
max_nesting_depth = 1000,
1163
1164
max_filesize = 100000000,
1164
1165
load_from_string = false,
1165
-
encode_datetime_as= "string",
1166
+
parse_datetime_as= "string",
1166
1167
type_conversion = {
1167
1168
["datetime"] = generic_type_conversion,
1168
1169
["datetime-local"] = generic_type_conversion,
@@ -1185,8 +1186,8 @@ function tinytoml.parse(filename: string, options?: TinyTomlOptions): {string:an
1185
1186
assert(type(options.load_from_string) =="boolean", "the tinytoml option 'load_from_string' takes in a 'function'. You passed in the value '"..tostring(options.load_from_string) .."' of type '"..type(options.load_from_string) .."'")
1186
1187
end
1187
1188
1188
-
if options.encode_datetime_as~=nilthen
1189
-
assert(type(options.encode_datetime_as) =="string", "the tinytoml option 'encode_datetime_as' takes in either the 'string' or 'table' (as type 'string'). You passed in the value '"..tostring(options.encode_datetime_as) .."' of type '"..type(options.encode_datetime_as) .."'")
1189
+
if options.parse_datetime_as~=nilthen
1190
+
assert(type(options.parse_datetime_as) =="string", "the tinytoml option 'parse_datetime_as' takes in either the 'string' or 'table' (as type 'string'). You passed in the value '"..tostring(options.parse_datetime_as) .."' of type '"..type(options.parse_datetime_as) .."'")
1190
1191
end
1191
1192
1192
1193
if options.type_conversion~=nilthen
@@ -1204,7 +1205,7 @@ function tinytoml.parse(filename: string, options?: TinyTomlOptions): {string:an
0 commit comments