-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Fix repr on Period Types, and DateTime, Date
#30817
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
Conversation
|
Nice, thank you (and welcome)! Not directly related, but I also notice Dates defines a few methods for |
base/number.jl
Outdated
| julia> import Dates; oneunit(Dates.Day) | ||
| 1 day | ||
| Dates.Day(1) |
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.
This isn't quite right --- 1 day should still be printed in the REPL, but repr should give Dates.Day(1). The BitPeriod type can be removed, and instead the current show method should be a method show(io::IO, ::MIME"text/plain", p::Period), and your new method might not be necessary since the fallback 2-argument show will probably print Dates.Day(1).
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.
Right, I see what you're saying. I think my latest change should satisfy those requirements, while also satisfying 1 day being shown in outputs such as in a dataframe.
- Given `x = Dates.Day(1)` - The REPL will print: `1 day` - show will print: `Dates.Day(1)` - repr will print: `Dates.Day(1)` - print will print: `1 day` - string will print: `1 day` - dataframes will print: `1 day`
omus
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.
Nice work 👍
|
Looks like the macOS build failed trying to pull a package |
|
@JeffBezanson does this look good to you? |
Related to these Dates stdlib changes: - JuliaLang/julia#30200 - JuliaLang/julia#30817
* Overhaul printing of types Related to these Dates stdlib changes: - JuliaLang/julia#30200 - JuliaLang/julia#30817 * Review comments
* Overhaul printing of types Related to these Dates stdlib changes: - JuliaLang/julia#30200 - JuliaLang/julia#30817 * Review comments
Jumping off of this previous PR #30200
It seems the
Periodtypes face a similar issue.Year,Month,Week,Day,Hour,Minute,Second,Millisecond,Microsecond, andNanosecondRealistically this should show the equivalent
reprtype output.Hour(1)I also noticed that the previous PR that is referenced in this one prints out "DateTime" or "Date" regardless of how Dates was imported.
importvsusing.When using import, you would expect
and with using, you would expect