# stdlib dateformat parsing is inconsistent, creates 32-bit issue

**URL:** <https://discourse.julialang.org/t/stdlib-dateformat-parsing-is-inconsistent-creates-32-bit-issue/21886>\
**Category:** Internals & Design\
**Tags:** dates\
**Created:** [March 14, 2019, 7:32pm UTC](https://discourse.julialang.org/t/stdlib-dateformat-parsing-is-inconsistent-creates-32-bit-issue/21886 "2019-03-14T19:32:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fchorney](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fchorney/32/7430_2.png) [@fchorney](https://discourse.julialang.org/u/fchorney)\
**Post date:** [March 14, 2019, 7:32pm UTC](https://discourse.julialang.org/t/stdlib-dateformat-parsing-is-inconsistent-creates-32-bit-issue/21886/1 "2019-03-14T19:32:05Z")

</div>

The tl;dr of this is that when julia does DateTime parsing, it tends to cast any resulting int values to Int64 (year, month, day, etc). Specifically on the “u” or “U” dateformat (which is either abbreviated month i.e. jan, or full month name i.e. January) julia will return an Int32 on 32-bit machines as that code path does not cast the result to an Int64.

I have more details in the following link to an issue, but I will copy/paste the important parts here as well

> <https://github.com/JuliaTime/TimeZones.jl/issues/187#issuecomment-473012078>
>
> Using 0.8.5
> 
> \`\`\`julia
> julia\> using Dates, TimeZones
> 
> julia\> zt = parse(Zone…dDateTime, "Feb 5 00:00:00 2019 GMT", dateformat"u d H:M:S Y Z")
> ERROR: MethodError: no method matching ZonedDateTime(::Int64, ::Int32, ::Int64, ::Int64, ::Int64, ::Int64, ::Int64, ::SubString{String})
> Closest candidates are:
> ZonedDateTime(::Int64, ::Int64, ::Int64, ::Int64, ::Int64, ::Int64, ::Int64, ::AbstractString) at /root/.julia/packages/TimeZones/WMDpl/src/types.jl:252
> ZonedDateTime(::Integer, ::Integer, ::Integer, ::Integer, ::Integer, ::Integer, ::Integer, ::VariableTimeZone, ::Integer) at /root/.julia/packages/TimeZones/WMDpl/src/types.jl:242
> ZonedDateTime(::Integer, ::Integer, ::Integer, ::Integer, ::Integer, ::Integer, ::Integer, ::TimeZone) at /root/.julia/packages/TimeZones/WMDpl/src/types.jl:246
> ...
> Stacktrace:
> \[1\] parse(::Type{ZonedDateTime}, ::String, ::DateFormat{Symbol("u d H:M:S Y Z"),Tuple{Dates.DatePart{'u'},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{'Y'},Dates.Delim{Char,1},Dates.DatePart{'Z'}}}) at /buildworker/worker/package\_linux32/build/usr/share/julia/stdlib/v1.0/Dates/src/parse.jl:285
> \[2\] top-level scope at none:0
> \`\`\`
> Looks like https://github.com/JuliaTime/TimeZones.jl/blob/v0.8.5/src/types.jl#L251 expects all the arguments to be Int64, but on a 32-bit system that's not the case.

> Specifically this line [https://github.com/JuliaLang/julia/blob/a7fabc91638064ebbad03831881b1459d4b92bd5/stdlib/Dates/src/query.jl#L73](https://github.com/JuliaLang/julia/blob/a7fabc91638064ebbad03831881b1459d4b92bd5/stdlib/Dates/src/query.jl#L73)`value` should be something like `value::Int64` . On 32 bit systems, this will return as a 32 bit value and will fail at this function [https://github.com/JuliaTime/TimeZones.jl/blob/master/src/types/zoneddatetime.jl#L121](https://github.com/JuliaTime/TimeZones.jl/blob/master/src/types/zoneddatetime.jl#L121) since it expects all inputs to be Int64
> 
> I’ll note that the other non lookup conversion values (year, month, day) they get casted to an Int64 [https://github.com/JuliaLang/julia/blob/a7fabc91638064ebbad03831881b1459d4b92bd5/stdlib/Dates/src/parse.jl#L163](https://github.com/JuliaLang/julia/blob/a7fabc91638064ebbad03831881b1459d4b92bd5/stdlib/Dates/src/parse.jl#L163) so it seems like the text version of the month is the only value that this problem exists for.

A 32-bit value is also returned for DoW conversions as it follows a similar path as the month conversions.

I wasn’t sure if this really warranted a bug issue on github, so I figured I’d bring it here first to see if anybody had any thoughts on it.

Thanks!

---

<div class="post-metadata">

**Author:** ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Post date:** [March 15, 2019, 9:02am UTC](https://discourse.julialang.org/t/stdlib-dateformat-parsing-is-inconsistent-creates-32-bit-issue/21886/2 "2019-03-15T09:02:42Z")

</div>

Yes. The inconsistency you note is an important one to remedy. They should be cast to the same specific Signed type ( `Int64`). Where `Int` or `Int32` appears, its likely an oversight.

You should note both the Month and the DoW are forcing `Int32`s into an `Int64` processing context. While you are checking, also reconfirm that the remaining DateTime elements are being treated as Int64s (an `Int32` Minute would cause similar issues). Thanks.

---

<div class="post-metadata">

**Author:** ![fchorney](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fchorney/32/7430_2.png) [@fchorney](https://discourse.julialang.org/u/fchorney)\
**Post date:** [March 15, 2019, 8:00pm UTC](https://discourse.julialang.org/t/stdlib-dateformat-parsing-is-inconsistent-creates-32-bit-issue/21886/3 "2019-03-15T20:00:25Z")

</div>

Thanks for the reply. I have opened up an issue in the julia github project [Dateparsing Returning Inconsistent Integer Types · Issue #31363 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/31363)

I have done some research, and based on what I found I believe that all the other date parsing flags are being converted to Int64 at some point, and only the month and DoW string to integer replacements are affected by this.

---

<div class="post-metadata">

**Author:** ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Post date:** [March 15, 2019, 9:59pm UTC](https://discourse.julialang.org/t/stdlib-dateformat-parsing-is-inconsistent-creates-32-bit-issue/21886/4 "2019-03-15T21:59:25Z")

</div>

👌
