-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Fix repr
on Period
Types, and DateTime
, Date
#30817
Conversation
Nice, thank you (and welcome)! Not directly related, but I also notice Dates defines a few methods for |
base/number.jl
Outdated
@@ -314,7 +314,7 @@ julia> oneunit(3.7) | |||
1.0 | |||
|
|||
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`
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
Period
types face a similar issue.Year
,Month
,Week
,Day
,Hour
,Minute
,Second
,Millisecond
,Microsecond
, andNanosecond
Realistically this should show the equivalent
repr
type 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.
import
vsusing
.When using import, you would expect
and with using, you would expect