at(dt::DateTime, t::Time) and at(d::Date, t::Time) #24814
Open
Description
opened on Nov 28, 2017
Hello,
Julia now have a Time type thanks to @aviks issue #12140 and @quinnj PR #12274
but a function that returns DateTime at a given Time (from either a Date or a DateTime)
could be a nice feature to have.
Usage example :
with DateTime
julia> dt = DateTime(2010, 1, 3, 20, 30)
2010-01-03T20:30:00
julia> at(dt, Dates.Time(13, 30))
2010-01-03T13:30:00
with Date
julia> d = Date(2010, 1, 1)
2010-01-03
julia> at(dt, Dates.Time(13, 30))
2010-01-03T13:30:00
This is a bit out of the scope of this issue but creating a DateTime from Date and Time is not as easy as it should be
julia> dt = DateTime(2010, 1, 3, 20, 30)
2010-01-03T20:30:00
julia> d = Date(dt)
2010-01-03
julia> t = Dates.Time(dt)
20:30:00
julia> DateTime(d, t)
ERROR: MethodError: Cannot `convert` an object of type Base.Dates.Time to an object of type Int64
This may have arisen from a call to the constructor Int64(...),
since type constructors fall back to convert methods.
Stacktrace:
[1] DateTime(::Date, ::Base.Dates.Time) at ./dates/types.jl:311
Kind regards
Activity