-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Reserve alphabetic characters for DateFormat codes
#38959
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
base: master
Are you sure you want to change the base?
Conversation
quinnj
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with the change; is it breaking though? I don't quite understand the implications of the change wrt to whether it breaks existing code.
|
The current documentation for Dates.Format says:
So this is clearly a breaking change; it even breaks an example given in the documentation. It is also a very useful change, but it ought to be introduced gradually. Suggestion: Starting in release 1.6, change merely the documentation to
Then add a deprecation warning in 1.7, and finally make it an error in 1.8 |
|
I would suggest to turn this into three separate PRs:
|
|
There are no deprecation cycles in the 1.x series. If this is considered a "major change" (i.e. existing users are very likely to run into it), then it will have to wait until 2.x. The behavior could be introduced with a keyword argument though. |
| @@ -0,0 +1,9 @@ | |||
| struct UndefDateFormatCode <: Exception | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a quick check.
Right now if open a repl and run subtypes(Exception)
there are 61 types shown.
The only ones that don't end with Exception or Error are:
SegmentationFault, and DimensionMismatch
Should we instead name this
| struct UndefDateFormatCode <: Exception | |
| struct DateFormatCodeUndefinedException <: Exception |
|
Triage thinks this is the right thing to do in theory, but if there are common date formats (e.g. including |
|
If this is better but the only problem is it's breaking, and the PR works otherwise, can this be slightly changed with a keyword argument to get this into 1.10.x? Might be to late for 1.10.0, but it probably will not become LTS anyway. |
As reported in JuliaTime/TimeZones.jl#303 when users use
Zwithout using the TimeZones package then theDateFormattreatsZas a delimiter:When using the TimeZones package the same code will fail as
Zis treated as aDatePartto be parsed:Ever since Dates parsing/formatting was made extensible there has also existed a workaround to this problem by escaping any characters meant to be treated as literal characters (delimiters) instead of interpreted as character codes (e.g.
dateformat"yyyy-mm-dd\THH:MM:SS\Z"). However, most users seem unaware of this functionality and are confused by the behaviour change when a package is imported.This PR reserves alphabetic characters (
[A-Za-z]) for use as character codes. If a user specifies one of these characters without a defined behavior an exception is now raised informing the user to either escape the character or import the package that defines the behavior.Note: In the process of updating this I noticed a particular test ensuring that a character code used twice would result in an exception. Unfortunately the test was flawed and once addressed it revealed the bug: