Skip to content
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

Better printing for TimeSpans #62

Open
ericphanson opened this issue Jan 31, 2024 · 3 comments
Open

Better printing for TimeSpans #62

ericphanson opened this issue Jan 31, 2024 · 3 comments

Comments

@ericphanson
Copy link
Member

Currently, we print them as things like TimeSpan(00:00:00.000000000, 09:45:00.000000000). This can be nice since it's "readable" but it is frustrating if you need to copy-paste into a REPL or such. I think we should use a roundtrippable implementation.

One option if we are attached to the current printing is to print it like

TimeSpan("00:00:00.000000000", "09:45:07.000000000")

(with quotes) and add a TimeSpan(::AbstractString, ::AbstractString) constructor to parse the strings.

@kleinschmidt
Copy link
Member

Does repr give you something useful? IIUC that's meant to be the "gimme a string I can eval to get this thing back" function, not print

@ericphanson
Copy link
Member Author

ericphanson commented Jan 31, 2024

It does not:

julia> repr(TimeSpan(0,1))
"TimeSpan(00:00:00.000000000, 00:00:00.000000001)"

Also:

help?> repr
search: repr replaceproperty! reinterpret repeat replace replace! replacefield!

  repr(x; context=nothing)

  Create a string from any value using the show function. You should not add
  methods to repr; define a show method instead.

@kleinschmidt
Copy link
Member

huh, well there ya go. adding a string constructor and putting quotes around makes the most sense to me then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants