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

Inconsistent behavior of Dates.now () when milliseconds are zero #42786

Open
UniqueTokens opened this issue Oct 24, 2021 · 1 comment
Open

Inconsistent behavior of Dates.now () when milliseconds are zero #42786

UniqueTokens opened this issue Oct 24, 2021 · 1 comment
Labels
domain:dates Dates, times, and the Dates stdlib module domain:display and printing Aesthetics and correctness of printed representations of objects. stdlib Julia's standard library

Comments

@UniqueTokens
Copy link

It would be nice if Dates.now() would always show the milliseconds, even if they are zero.

Current behavior: 2021-10-24T15:55:06

Expected behavior: 2021-10-24T15:55:06.000

Minimal working example

using Dates

while true
    now = string(Dates.now())
    if length(now) != 23
        println(now)
        break
    end
end
@ararslan
Copy link
Member

As a general breadcrumb, this seems to be done explicitly: https://github.com/JuliaLang/julia/blob/master/stdlib/Dates/src/io.jl#L684-L691. Git blame shows that 0 milliseconds has been truncated for many years at this point.

@ararslan ararslan added domain:dates Dates, times, and the Dates stdlib module domain:display and printing Aesthetics and correctness of printed representations of objects. stdlib Julia's standard library labels Oct 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:dates Dates, times, and the Dates stdlib module domain:display and printing Aesthetics and correctness of printed representations of objects. stdlib Julia's standard library
Projects
None yet
Development

No branches or pull requests

2 participants