julia
317211a3 - Dates: Error on construction/parsing with empty strings (#47117)

Commit
3 years ago
Dates: Error on construction/parsing with empty strings (#47117) When attempting to construct a `DateTime`, `Date` or `Time` from an `AbstractString`, throw an `ArgumentError` if the string is empty. Likewise, error when `parse`ing an empty string as one of these types, and return `nothing` from `tryparse`. This behavior differs from previously. Before, `Date` and `Time` would return default values of `Date(1)` and `Time(0)`, respectively, while `DateTime` would error without a `format` argument. With a `format` argument, it would return `DateTime(1)`. However, this appears not to have been explicitly intended, but rather a consequence of the way parsing was implemented; no tests for empty string parsing existed. This addresses #28090 and #43883; see discussion therein. Summary of changes: - Check for empty string in `Base.parse(::DateTime)` and throw if so. - Change documentation to mention this. - Add a compat notice to the docs contrasting the old behavior.
Author
Parents
Loading