Better DOY Conversion?

dates

#1

Is there an easy way of converting a DateTime to a string with Day Of Year (DOY)?

julia> time = DateTime(2017,5,16,14,20)
julia> floor(convert(Float64,time - DateTime(Dates.Year(time)) + DateTime(Dates.Day(1)))/1000/60/60/24)
136.0

Ideally I could just do something like this.

julia> dfmt = Dates.DateFormat("yyyyddd_HHMMSS")
julia> Dates.format(time,dfmt)
"2017136_142000"

Dates doesn’t appear to have a DOY formatting string though.

https://github.com/JuliaLang/julia/blob/master/test/dates/io.jl


#2
julia> time = DateTime(2017,5,16,14,20)
julia> Dates.dayofyear(time)

It would be good if there was a format string option, though.


#3

No idea how I missed that one but thank you for pointing that out. If I ever figure out Github I’ll see if I can add a DOY option to the formats.


#4

You could start by opening an issue :thumbsup: