<p dir="auto">Currently Julia supports only millisecond resolution through its <code class="notranslate">Datetime</code> type (in the standard <code class="notranslate">Dates</code> package). That is, it can accept date and time in the format</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="julia&gt; df = DateFormat(&quot;Y-m-d H:M:S.s&quot;)
dateformat&quot;Y-m-d H:M:S.s&quot;"><pre class="notranslate">julia<span class="pl-k">&gt;</span> df <span class="pl-k">=</span> <span class="pl-c1">DateFormat</span>(<span class="pl-s"><span class="pl-pds">"</span>Y-m-d H:M:S.s<span class="pl-pds">"</span></span>)
<span class="pl-s"><span class="pl-pds"><span class="pl-c1">dateformat</span>"</span>Y-m-d H:M:S.s<span class="pl-pds">"</span></span></pre></div>
<p dir="auto">where the <code class="notranslate">s</code> after the decimal dot is only allowed to have up to three figures. In order words, there must be an integer number of millisecond.</p>
<p dir="auto">A working example is below</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="julia&gt; DateTime(&quot;2019-12-06 12:01:40.301&quot;,df)
2019-12-06T12:01:40.301"><pre class="notranslate">julia<span class="pl-k">&gt;</span> <span class="pl-c1">DateTime</span>(<span class="pl-s"><span class="pl-pds">"</span>2019-12-06 12:01:40.301<span class="pl-pds">"</span></span>,df)
<span class="pl-c1">2019</span><span class="pl-k">-</span><span class="pl-c1">12</span><span class="pl-k">-</span><span class="pl-c1">06</span>T12<span class="pl-k">:</span><span class="pl-c1">01</span><span class="pl-k">:</span><span class="pl-c1">40.301</span></pre></div>
<p dir="auto">But another example below does not work</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="julia&gt; DateTime(&quot;2019-12-06 12:01:40.301199&quot;,df)
ERROR: InexactError: convert(Dates.Decimal3, 301199)
Stacktrace:
 [1] tryparsenext at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.3/Dates/src/io.jl:153 [inlined]
 [2] tryparsenext at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.3/Dates/src/io.jl:41 [inlined]
 [3] macro expansion at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.3/Dates/src/parse.jl:64 [inlined]
 [4] tryparsenext_core(::String, ::Int64, ::Int64, ::DateFormat{Symbol(&quot;Y-m-d H:M:S.s&quot;),Tuple{Dates.DatePart{'Y'},Dates.Delim{Char,1},Dates.DatePart{'m'},Dates.Delim{Char,1},Dates.DatePart{'d'},Dates.Delim{Char,1},Dates.DatePart{'H'},Dates.Delim{Char,1},Dates.DatePart{'M'},Dates.Delim{Char,1},Dates.DatePart{'S'},Dates.Delim{Char,1},Dates.DatePart{'s'}}}, ::Bool) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.3/Dates/src/parse.jl:40
 [5] macro expansion at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.3/Dates/src/parse.jl:150 [inlined]
 [6] tryparsenext_internal at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.3/Dates/src/parse.jl:127 [inlined]
 [7] parse(::Type{DateTime}, ::String, ::DateFormat{Symbol(&quot;Y-m-d H:M:S.s&quot;),Tuple{Dates.DatePart{'Y'},Dates.Delim{Char,1},Dates.DatePart{'m'},Dates.Delim{Char,1},Dates.DatePart{'d'},Dates.Delim{Char,1},Dates.DatePart{'H'},Dates.Delim{Char,1},Dates.DatePart{'M'},Dates.Delim{Char,1},Dates.DatePart{'S'},Dates.Delim{Char,1},Dates.DatePart{'s'}}}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.3/Dates/src/parse.jl:282
 [8] DateTime(::String, ::DateFormat{Symbol(&quot;Y-m-d H:M:S.s&quot;),Tuple{Dates.DatePart{'Y'},Dates.Delim{Char,1},Dates.DatePart{'m'},Dates.Delim{Char,1},Dates.DatePart{'d'},Dates.Delim{Char,1},Dates.DatePart{'H'},Dates.Delim{Char,1},Dates.DatePart{'M'},Dates.Delim{Char,1},Dates.DatePart{'S'},Dates.Delim{Char,1},Dates.DatePart{'s'}}}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.3/Dates/src/io.jl:482
 [9] top-level scope at none:0"><pre class="notranslate">julia<span class="pl-k">&gt;</span> <span class="pl-c1">DateTime</span>(<span class="pl-s"><span class="pl-pds">"</span>2019-12-06 12:01:40.301199<span class="pl-pds">"</span></span>,df)
ERROR<span class="pl-k">:</span> InexactError<span class="pl-k">:</span> <span class="pl-c1">convert</span>(Dates<span class="pl-k">.</span>Decimal3, <span class="pl-c1">301199</span>)
Stacktrace<span class="pl-k">:</span>
 [<span class="pl-c1">1</span>] tryparsenext at <span class="pl-k">/</span>buildworker<span class="pl-k">/</span>worker<span class="pl-k">/</span>package_linux64<span class="pl-k">/</span>build<span class="pl-k">/</span>usr<span class="pl-k">/</span>share<span class="pl-k">/</span>julia<span class="pl-k">/</span>stdlib<span class="pl-k">/</span>v1.<span class="pl-c1">3</span><span class="pl-k">/</span>Dates<span class="pl-k">/</span>src<span class="pl-k">/</span>io<span class="pl-k">.</span>jl<span class="pl-k">:</span><span class="pl-c1">153</span> [inlined]
 [<span class="pl-c1">2</span>] tryparsenext at <span class="pl-k">/</span>buildworker<span class="pl-k">/</span>worker<span class="pl-k">/</span>package_linux64<span class="pl-k">/</span>build<span class="pl-k">/</span>usr<span class="pl-k">/</span>share<span class="pl-k">/</span>julia<span class="pl-k">/</span>stdlib<span class="pl-k">/</span>v1.<span class="pl-c1">3</span><span class="pl-k">/</span>Dates<span class="pl-k">/</span>src<span class="pl-k">/</span>io<span class="pl-k">.</span>jl<span class="pl-k">:</span><span class="pl-c1">41</span> [inlined]
 [<span class="pl-c1">3</span>] <span class="pl-k">macro</span> expansion at <span class="pl-k">/</span>buildworker<span class="pl-k">/</span>worker<span class="pl-k">/</span>package_linux64<span class="pl-k">/</span>build<span class="pl-k">/</span>usr<span class="pl-k">/</span>share<span class="pl-k">/</span>julia<span class="pl-k">/</span>stdlib<span class="pl-k">/</span>v1.<span class="pl-c1">3</span><span class="pl-k">/</span>Dates<span class="pl-k">/</span>src<span class="pl-k">/</span>parse<span class="pl-k">.</span>jl<span class="pl-k">:</span><span class="pl-c1">64</span> [inlined]
 [<span class="pl-c1">4</span>] <span class="pl-c1">tryparsenext_core</span>(<span class="pl-k">::</span><span class="pl-c1">String</span>, <span class="pl-k">::</span><span class="pl-c1">Int64</span>, <span class="pl-k">::</span><span class="pl-c1">Int64</span>, <span class="pl-k">::</span><span class="pl-c1">DateFormat{Symbol("Y-m-d H:M:S.s"),Tuple{Dates.DatePart{'Y'},Dates.Delim{Char,1},Dates.DatePart{'m'},Dates.Delim{Char,1},Dates.DatePart{'d'},Dates.Delim{Char,1},Dates.DatePart{'H'},Dates.Delim{Char,1},Dates.DatePart{'M'},Dates.Delim{Char,1},Dates.DatePart{'S'},Dates.Delim{Char,1},Dates.DatePart{'s'}}}</span>, <span class="pl-k">::</span><span class="pl-c1">Bool</span>) at <span class="pl-k">/</span>buildworker<span class="pl-k">/</span>worker<span class="pl-k">/</span>package_linux64<span class="pl-k">/</span>build<span class="pl-k">/</span>usr<span class="pl-k">/</span>share<span class="pl-k">/</span>julia<span class="pl-k">/</span>stdlib<span class="pl-k">/</span>v1.<span class="pl-c1">3</span><span class="pl-k">/</span>Dates<span class="pl-k">/</span>src<span class="pl-k">/</span>parse<span class="pl-k">.</span>jl<span class="pl-k">:</span><span class="pl-c1">40</span>
 [<span class="pl-c1">5</span>] <span class="pl-k">macro</span> expansion at <span class="pl-k">/</span>buildworker<span class="pl-k">/</span>worker<span class="pl-k">/</span>package_linux64<span class="pl-k">/</span>build<span class="pl-k">/</span>usr<span class="pl-k">/</span>share<span class="pl-k">/</span>julia<span class="pl-k">/</span>stdlib<span class="pl-k">/</span>v1.<span class="pl-c1">3</span><span class="pl-k">/</span>Dates<span class="pl-k">/</span>src<span class="pl-k">/</span>parse<span class="pl-k">.</span>jl<span class="pl-k">:</span><span class="pl-c1">150</span> [inlined]
 [<span class="pl-c1">6</span>] tryparsenext_internal at <span class="pl-k">/</span>buildworker<span class="pl-k">/</span>worker<span class="pl-k">/</span>package_linux64<span class="pl-k">/</span>build<span class="pl-k">/</span>usr<span class="pl-k">/</span>share<span class="pl-k">/</span>julia<span class="pl-k">/</span>stdlib<span class="pl-k">/</span>v1.<span class="pl-c1">3</span><span class="pl-k">/</span>Dates<span class="pl-k">/</span>src<span class="pl-k">/</span>parse<span class="pl-k">.</span>jl<span class="pl-k">:</span><span class="pl-c1">127</span> [inlined]
 [<span class="pl-c1">7</span>] <span class="pl-c1">parse</span>(<span class="pl-k">::</span><span class="pl-c1">Type{DateTime}</span>, <span class="pl-k">::</span><span class="pl-c1">String</span>, <span class="pl-k">::</span><span class="pl-c1">DateFormat{Symbol("Y-m-d H:M:S.s"),Tuple{Dates.DatePart{'Y'},Dates.Delim{Char,1},Dates.DatePart{'m'},Dates.Delim{Char,1},Dates.DatePart{'d'},Dates.Delim{Char,1},Dates.DatePart{'H'},Dates.Delim{Char,1},Dates.DatePart{'M'},Dates.Delim{Char,1},Dates.DatePart{'S'},Dates.Delim{Char,1},Dates.DatePart{'s'}}}</span>) at <span class="pl-k">/</span>buildworker<span class="pl-k">/</span>worker<span class="pl-k">/</span>package_linux64<span class="pl-k">/</span>build<span class="pl-k">/</span>usr<span class="pl-k">/</span>share<span class="pl-k">/</span>julia<span class="pl-k">/</span>stdlib<span class="pl-k">/</span>v1.<span class="pl-c1">3</span><span class="pl-k">/</span>Dates<span class="pl-k">/</span>src<span class="pl-k">/</span>parse<span class="pl-k">.</span>jl<span class="pl-k">:</span><span class="pl-c1">282</span>
 [<span class="pl-c1">8</span>] <span class="pl-c1">DateTime</span>(<span class="pl-k">::</span><span class="pl-c1">String</span>, <span class="pl-k">::</span><span class="pl-c1">DateFormat{Symbol("Y-m-d H:M:S.s"),Tuple{Dates.DatePart{'Y'},Dates.Delim{Char,1},Dates.DatePart{'m'},Dates.Delim{Char,1},Dates.DatePart{'d'},Dates.Delim{Char,1},Dates.DatePart{'H'},Dates.Delim{Char,1},Dates.DatePart{'M'},Dates.Delim{Char,1},Dates.DatePart{'S'},Dates.Delim{Char,1},Dates.DatePart{'s'}}}</span>) at <span class="pl-k">/</span>buildworker<span class="pl-k">/</span>worker<span class="pl-k">/</span>package_linux64<span class="pl-k">/</span>build<span class="pl-k">/</span>usr<span class="pl-k">/</span>share<span class="pl-k">/</span>julia<span class="pl-k">/</span>stdlib<span class="pl-k">/</span>v1.<span class="pl-c1">3</span><span class="pl-k">/</span>Dates<span class="pl-k">/</span>src<span class="pl-k">/</span>io<span class="pl-k">.</span>jl<span class="pl-k">:</span><span class="pl-c1">482</span>
 [<span class="pl-c1">9</span>] top<span class="pl-k">-</span>level scope at none<span class="pl-k">:</span><span class="pl-c1">0</span></pre></div>
<p dir="auto">Obviously, microseconds are not allowed in <code class="notranslate">DateTime</code> type.</p>
<p dir="auto">Although the <code class="notranslate">Time</code> type defined in the same built-in <code class="notranslate">Dates</code> package does allow for microseconds and even nanoseconds, constructing <code class="notranslate">Time</code> type variable by <a href="https://docs.julialang.org/en/v1/stdlib/Dates/#Dates.Time-Tuple%7BDateTime%7D" rel="nofollow">calling Time on DateTime</a> is limited in the same way.</p>
<p dir="auto">And yet allowing microseconds might be useful on some occasions (time from a GNSS receiver, for example). Furthermore, in Python their built-in <code class="notranslate">datetime</code> module does allow for microseconds in their <a href="https://docs.python.org/3.8/library/datetime.html#datetime.datetime" rel="nofollow">datetime</a> and <a href="https://docs.python.org/3.8/library/datetime.html#datetime.time" rel="nofollow">time</a> objects; interestingly enough, it only stores the subsecond time in (integer) microseconds.</p>
<p dir="auto">I am willing to prepare a PR, but first I wanted to ask what is the general viewpoint. Is there a chance that such an extension of Julia's <code class="notranslate">DateTime</code> and <code class="notranslate">Time</code> types could be accepted? I think it can be prepared such that it does not break an older code. But I am asking first because maybe there was already some discussion of this and the current state of things is a result of a decision supported by some arguments.</p>
<p dir="auto">While trying to parse our AV logs (<a href="https://ci.appveyor.com/api/projects/JuliaLang/julia/history?recordsNumber=1&amp;startBuildId=20355614" rel="nofollow">https://ci.appveyor.com/api/projects/JuliaLang/julia/history?recordsNumber=1&amp;startBuildId=20355614</a>), I realized that we apparently can't handle times more precise than milliseconds (even though we have Dates.Microsecond):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="julia&gt; DateTime(&quot;2018-11-16T10:26:14.2858074Z&quot;, dateformat&quot;YYYY-MM-ddTHH:MM:SS.sZ&quot;)
ERROR: InexactError: convert(Dates.Decimal3, 2858074)
Stacktrace:
 [1] tryparsenext at /data/vtjnash/julia/usr/share/julia/stdlib/v1.2/Dates/src/io.jl:119 [inlined]
 [2] tryparsenext at /data/vtjnash/julia/usr/share/julia/stdlib/v1.2/Dates/src/io.jl:41 [inlined]
 [3] macro expansion at /data/vtjnash/julia/usr/share/julia/stdlib/v1.2/Dates/src/parse.jl:64 [inlined]
 [4] tryparsenext_core(::String, ::Int64, ::Int64, ::DateFormat{Symbol(&quot;YYYY-MM-ddTHH:MM:SS.sZ&quot;),Tuple{Dates.DatePart{'Y'},Dates.Delim{Char,1},Dates.DatePart{'M'},Dates.Delim{Char,1},Date
s.DatePart{'d'},Dates.Delim{Char,1},Dates.DatePart{'H'},Dates.Delim{Char,1},Dates.DatePart{'M'},Dates.Delim{Char,1},Dates.DatePart{'S'},Dates.Delim{Char,1},Dates.DatePart{'s'},Dates.Delim{Char,1}}}, ::Bool) at /data/vtjnash/julia/usr/share/julia/stdlib/v1.2/Dates/src/parse.jl:40
 [5] macro expansion at /data/vtjnash/julia/usr/share/julia/stdlib/v1.2/Dates/src/parse.jl:150 [inlined]
 [6] tryparsenext_internal at /data/vtjnash/julia/usr/share/julia/stdlib/v1.2/Dates/src/parse.jl:127 [inlined]
 [7] parse(::Type{DateTime}, ::String, ::DateFormat{Symbol(&quot;YYYY-MM-ddTHH:MM:SS.sZ&quot;),Tuple{Dates.DatePart{'Y'},Dates.Delim{Char,1},Dates.DatePart{'M'},Dates.Delim{Char,1},Dates.DatePart{'d'},Dates.Delim{Char,1},Dates.DatePart{'H'},Dates.Delim{Char,1},Dates.DatePart{'M'},Dates.Delim{Char,1},Dates.DatePart{'S'},Dates.Delim{Char,1},Dates.DatePart{'s'},Dates.Delim{Char,1}}}) at /data/vtjnash/julia/usr/share/julia/stdlib/v1.2/Dates/src/parse.jl:282
 [8] DateTime(::String, ::DateFormat{Symbol(&quot;YYYY-MM-ddTHH:MM:SS.sZ&quot;),Tuple{Dates.DatePart{'Y'},Dates.Delim{Char,1},Dates.DatePart{'M'},Dates.Delim{Char,1},Dates.DatePart{'d'},Dates.Delim{Char,1},Dates.DatePart{'H'},Dates.Delim{Char,1},Dates.DatePart{'M'},Dates.Delim{Char,1},Dates.DatePart{'S'},Dates.Delim{Char,1},Dates.DatePart{'s'},Dates.Delim{Char,1}}}) at /data/vtjnash/julia/usr/share/julia/stdlib/v1.2/Dates/src/io.jl:432
 [9] top-level scope at REPL[87]:1"><pre class="notranslate"><code class="notranslate">julia&gt; DateTime("2018-11-16T10:26:14.2858074Z", dateformat"YYYY-MM-ddTHH:MM:SS.sZ")
ERROR: InexactError: convert(Dates.Decimal3, 2858074)
Stacktrace:
 [1] tryparsenext at /data/vtjnash/julia/usr/share/julia/stdlib/v1.2/Dates/src/io.jl:119 [inlined]
 [2] tryparsenext at /data/vtjnash/julia/usr/share/julia/stdlib/v1.2/Dates/src/io.jl:41 [inlined]
 [3] macro expansion at /data/vtjnash/julia/usr/share/julia/stdlib/v1.2/Dates/src/parse.jl:64 [inlined]
 [4] tryparsenext_core(::String, ::Int64, ::Int64, ::DateFormat{Symbol("YYYY-MM-ddTHH:MM:SS.sZ"),Tuple{Dates.DatePart{'Y'},Dates.Delim{Char,1},Dates.DatePart{'M'},Dates.Delim{Char,1},Date
s.DatePart{'d'},Dates.Delim{Char,1},Dates.DatePart{'H'},Dates.Delim{Char,1},Dates.DatePart{'M'},Dates.Delim{Char,1},Dates.DatePart{'S'},Dates.Delim{Char,1},Dates.DatePart{'s'},Dates.Delim{Char,1}}}, ::Bool) at /data/vtjnash/julia/usr/share/julia/stdlib/v1.2/Dates/src/parse.jl:40
 [5] macro expansion at /data/vtjnash/julia/usr/share/julia/stdlib/v1.2/Dates/src/parse.jl:150 [inlined]
 [6] tryparsenext_internal at /data/vtjnash/julia/usr/share/julia/stdlib/v1.2/Dates/src/parse.jl:127 [inlined]
 [7] parse(::Type{DateTime}, ::String, ::DateFormat{Symbol("YYYY-MM-ddTHH:MM:SS.sZ"),Tuple{Dates.DatePart{'Y'},Dates.Delim{Char,1},Dates.DatePart{'M'},Dates.Delim{Char,1},Dates.DatePart{'d'},Dates.Delim{Char,1},Dates.DatePart{'H'},Dates.Delim{Char,1},Dates.DatePart{'M'},Dates.Delim{Char,1},Dates.DatePart{'S'},Dates.Delim{Char,1},Dates.DatePart{'s'},Dates.Delim{Char,1}}}) at /data/vtjnash/julia/usr/share/julia/stdlib/v1.2/Dates/src/parse.jl:282
 [8] DateTime(::String, ::DateFormat{Symbol("YYYY-MM-ddTHH:MM:SS.sZ"),Tuple{Dates.DatePart{'Y'},Dates.Delim{Char,1},Dates.DatePart{'M'},Dates.Delim{Char,1},Dates.DatePart{'d'},Dates.Delim{Char,1},Dates.DatePart{'H'},Dates.Delim{Char,1},Dates.DatePart{'M'},Dates.Delim{Char,1},Dates.DatePart{'S'},Dates.Delim{Char,1},Dates.DatePart{'s'},Dates.Delim{Char,1}}}) at /data/vtjnash/julia/usr/share/julia/stdlib/v1.2/Dates/src/io.jl:432
 [9] top-level scope at REPL[87]:1
</code></pre></div>