From f5e7431771f80258a7740ae64aeb6cbe64256721 Mon Sep 17 00:00:00 2001 From: imreddyTeja Date: Thu, 12 Dec 2024 17:13:18 -0800 Subject: [PATCH] Remove date-string conversion functions 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. --- docs/src/timemanager.md | 2 -- src/TimeManager.jl | 27 --------------------------- test/time_manager_tests.jl | 10 ---------- 3 files changed, 39 deletions(-) diff --git a/docs/src/timemanager.md b/docs/src/timemanager.md index ed47e791c..f96a26452 100644 --- a/docs/src/timemanager.md +++ b/docs/src/timemanager.md @@ -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 diff --git a/src/TimeManager.jl b/src/TimeManager.jl index 92b41f19f..e579b97d9 100644 --- a/src/TimeManager.jl +++ b/src/TimeManager.jl @@ -10,8 +10,6 @@ import Dates import ..Interfacer export current_date, - strdate_to_datetime, - datetime_to_strdate, trigger_callback, AbstractFrequency, Monthly, @@ -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 diff --git a/test/time_manager_tests.jl b/test/time_manager_tests.jl index 2afbe2a8d..8887db9db 100644 --- a/test/time_manager_tests.jl +++ b/test/time_manager_tests.jl @@ -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")