-
Notifications
You must be signed in to change notification settings - Fork 5
Conversation
- Generating Dict similar to those used in Base.Dates eg. DAYOFWEEKTOVALUE
Current coverage is
|
Would like to "Perform |
"Eventually res could become |
"I'd also like _parsedate to be broken into smaller functions. For example extract just the timezone from the tokens" |
return i | ||
end | ||
|
||
function processymd!(res::Dict, ymd::Array, mstridx=-1; yearfirst=false, dayfirst=false) |
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.
Why not just have processymd
return a tuple of Year, Month, Day? ymd
should be ymd::Array{Int}
. mstridx
is a bad variable name and should be changed.
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.
Ok, I'll change it to return a tuple instead of passing res by reference. Any preferences on what I should rename mstridx to?
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.
month_index
?
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.
The reason why processymd
does not just return a Year, Month and Day is because there isn't always a Year, Month and Day to return.
i += 2 | ||
if i+1 <= len && tokens[i] == "." && isdigit(tokens[i+1]) | ||
res["millisecond"] = round(Int, 1000 * parse(Float64, string(".", tokens[i+1]))) | ||
temp = 1000 * parse(Float64, string(".", tokens[i+1])) | ||
res["millisecond"] = Millisecond(round(Int, temp)) | ||
i += 2 | ||
end | ||
end |
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.
Maybe this section is a little too fragile?
julia> parse(DateTime, "5:4.5")
2015-01-01T05:04:30
julia> parse(DateTime, "5:4:3.5")
2015-01-01T05:04:03.5
julia> parse(DateTime, "5:4.5:3.5")
ERROR: Failed to parse date
in _parsedate at /Users/omus/.julia/v0.4/DateTimeParser/src/DateTimeParser.jl:361
in parse at /Users/omus/.julia/v0.4/DateTimeParser/src/DateTimeParser.jl:92
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.
Ending with a decimal is a special case. I'm not sure we want to support having a floats in the middle.
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.
That's fair
Good work overall! |
|
res.month = get(res.month, Month(default)) | ||
res.day = get(res.day, Day(default)) | ||
|
||
return Date(get(res.year), get(res.month), get(res.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.
Could shorten the code to:
return Date(
get(res.year, year(default)),
get(res.month, month(default)),
get(res.day, day(default)),
)
@@ -152,25 +167,26 @@ function _parsedate(datetimestring::AbstractString; fuzzy::Bool=false, | |||
# Token is a number | |||
i += 1 # We want to look at what comes after the number | |||
if length(ymd) == 3 && tokenlength in (2,4) && | |||
(i>=len || (tokens[i] != ":" && !haskey(HMS, lowercase(tokens[i])))) | |||
(i>=len || (tokens[i] != ":" && !haskey(HMS[locale], lowercase(tokens[i])))) |
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.
Condition can be changed to length(ymd) == 3 && tokenlength in (2,4) && i > len
without causing the testcases to fail. Add additional tests?
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.
Ok, I'll add a test for it parse(DateTime, "19991212 0259+1:00")
The 32 bit win build is broken because the released TimeZones 32 bit build is broken |
Which is broken because LightXML 32-but is broken because WinRPM 32-bit is broken. All good |
Refactor DateTimeParser