As example, here is a DateTime
object declared below using Dates
module:
julia> using Dates
julia> dt = DateTime(2021, 05, 11, 18, 21, 50)
2021-05-11T18:21:50
We can find the Hour value of dt
simply using hour()
function from Dates
module:
julia> hour(dt)
18
We can prefix the module name with hour()
function also:
julia> Dates.hour(dt)
18
Now, if we try to use format()
function from Dates
module as below:
julia> format(dt, "e, H:M:S dd-u-yyyy")
ERROR: UndefVarError: format not defined
it throws error. We need to prefix module name here to make it work:
julia> Dates.format(dt, "e, H:M:S dd-u-yyyy")
"Tue, 18:21:50 11-May-2021"
Why do some functions in Julia need to be prefixed by the module name to work?