Skip to content

Commit

Permalink
backport zero function from @rafaqz
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Barth committed Jan 14, 2025
1 parent fd805d1 commit b390413
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ uuid = "179af706-886a-5703-950a-314cd64e0468"
keywords = ["time", "calendar", "netcdf", "climate and forecast conventions", "oceanography", "meteorology", "climatology", "opendap"]
license = "MIT"
desc = "Julia library for decoding time units conforming to the Climate and Forecasting (CF) netCDF conventions"
version = "0.1.3"
version = "0.1.4"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand Down
1 change: 1 addition & 0 deletions src/CFTime.jl
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ pattern given in the `format` string.
$CFDateTime(dt::AbstractString, format::DateFormat) =
parse($CFDateTime, dt, format)

Base.zero(::Type{$CFDateTime}) = Millisecond(0)
end
end

Expand Down
9 changes: 9 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,12 @@ using Printf
@testset "Time and calendars" begin
include("test_time.jl")
end

@testset "zero" begin
@test zero(DateTimeAllLeap) == CFTime.Millisecond(0)
@test zero(DateTimeNoLeap) == CFTime.Millisecond(0)
@test zero(DateTimeJulian) == CFTime.Millisecond(0)
@test zero(DateTimeJulian) == CFTime.Millisecond(0)
@test zero(DateTime360Day) == CFTime.Millisecond(0)
@test zero(DateTime360Day) == CFTime.Millisecond(0)
end

0 comments on commit b390413

Please sign in to comment.