Skip to content

Commit

Permalink
Remove date-string conversion functions
Browse files Browse the repository at this point in the history
The strdate_to_datetime and datetime_to_strdate are unused
after removing the Regridders module. Additionally, their funcitonality
is contained within the Dates package with Dates.format and
DateFormats.
  • Loading branch information
imreddyTeja committed Dec 17, 2024
1 parent 5a1d2f5 commit f5e7431
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 39 deletions.
2 changes: 0 additions & 2 deletions docs/src/timemanager.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ functions from Julia's [Dates](https://docs.julialang.org/en/v1/stdlib/Dates/) m

```@docs
ClimaCoupler.TimeManager.current_date
ClimaCoupler.TimeManager.strdate_to_datetime
ClimaCoupler.TimeManager.datetime_to_strdate
ClimaCoupler.TimeManager.trigger_callback
ClimaCoupler.TimeManager.AbstractFrequency
ClimaCoupler.TimeManager.Monthly
Expand Down
27 changes: 0 additions & 27 deletions src/TimeManager.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import Dates
import ..Interfacer

export current_date,
strdate_to_datetime,
datetime_to_strdate,
trigger_callback,
AbstractFrequency,
Monthly,
Expand All @@ -33,31 +31,6 @@ Return the model date at the current timestep.
"""
current_date(cs::Interfacer.CoupledSimulation, t::Real) = cs.dates.date0[1] + Dates.Second(t)

"""
strdate_to_datetime(strdate::String)
Convert from String ("YYYYMMDD") to Date format,
required by the official AMIP input files.
# Arguments
- `strdate`: [String] to be converted to Date type
"""
strdate_to_datetime(strdate::String) =
Dates.DateTime(parse(Int, strdate[1:4]), parse(Int, strdate[5:6]), parse(Int, strdate[7:8]))

"""
datetime_to_strdate(datetime::DateTime)
Convert from Date to String ("YYYYMMDD") format.
# Arguments
- `datetime`: [Dates.DateTime] object to be converted to string
"""
datetime_to_strdate(datetime::Dates.DateTime) =
string(lpad(Dates.year(datetime), 4, "0")) *
string(string(lpad(Dates.month(datetime), 2, "0"))) *
string(lpad(Dates.day(datetime), 2, "0"))

"""
AbstractFrequency
Expand Down
10 changes: 0 additions & 10 deletions test/time_manager_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,6 @@ for FT in (Float32, Float64)
end
end

@testset "test strdate_to_datetime" begin
@test TimeManager.strdate_to_datetime("19000101") == Dates.DateTime(1900, 1, 1)
@test TimeManager.strdate_to_datetime("00000101") == Dates.DateTime(0, 1, 1)
end

@testset "test datetime_to_strdate" begin
@test TimeManager.datetime_to_strdate(Dates.DateTime(1900, 1, 1)) == "19000101"
@test TimeManager.datetime_to_strdate(Dates.DateTime(0, 1, 1)) == "00000101"
end

@testset "trigger_callback" begin
FT = Float64
date0 = date = Dates.DateTime("19790321", Dates.dateformat"yyyymmdd")
Expand Down

0 comments on commit f5e7431

Please sign in to comment.