Skip to content

Commit

Permalink
Remove yyyymmdd_to_datetime function
Browse files Browse the repository at this point in the history
The functionality of the `yyyymmdd_to_datetime` function
is already contained in the Dates package.
  • Loading branch information
imreddyTeja committed Dec 16, 2024
1 parent c44fc47 commit 16eaf38
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions ext/nc_common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,8 @@ function read_available_dates(ds::NetCDFDataset)
reinterpret.(Ref(NCDatasets.DateTimeStandard), ds["time"][:])
)
elseif "date" in keys(ds.dim)
return yyyymmdd_to_datetime.(string.(ds["date"][:]))
return Dates.DateTime.(string.(ds["date"][:]), Ref("yyyymmdd"))
else
return Dates.DateTime[]
end
end

"""
strdate_to_datetime(strdate::String)
Convert from String ("YYYYMMDD") to Date format.
# Arguments
- `yyyymmdd`: [String] to be converted to Date type
"""
function yyyymmdd_to_datetime(strdate::String)
length(strdate) == 8 || error("$strdate does not have the YYYYMMDD format")
return Dates.DateTime(
parse(Int, strdate[1:4]),
parse(Int, strdate[5:6]),
parse(Int, strdate[7:8]),
)
end

0 comments on commit 16eaf38

Please sign in to comment.