Skip to content

Commit

Permalink
hack around libgit2 being in Base
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofferC committed Nov 20, 2017
1 parent cff4ebe commit 3830f66
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 7 additions & 1 deletion base/libgit2/signature.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,16 @@ function Base.convert(::Type{GitSignature}, sig::Signature)
return GitSignature(sig_ptr_ptr[])
end

# Work around needing to access Dates from Base,
# even though Dates is in the stdlib.
# This Ref is filled with the needed function
# when Dates is loaed
const unix2datetime = Ref{Any}()

function Base.show(io::IO, sig::Signature)
print(io, "Name: ", sig.name, ", ")
print(io, "Email: ", sig.email, ", ")
print(io, "Time: ", Dates.unix2datetime(sig.time + 60*sig.time_offset))
print(io, "Time: ", unix2datetime[](sig.time + 60*sig.time_offset))
@printf(io, "%+03i:%02i", divrem(sig.time_offset, 60)...)
end

Expand Down
2 changes: 2 additions & 0 deletions stdlib/Dates/src/Dates.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ include("io.jl")
include("parse.jl")
include("deprecated.jl")

Base.LibGit2.unix2datetime[] = unix2datetime

export Period, DatePeriod, TimePeriod,
Year, Month, Week, Day, Hour, Minute, Second, Millisecond,
Microsecond, Nanosecond,
Expand Down

0 comments on commit 3830f66

Please sign in to comment.