Skip to content

Commit

Permalink
test daysinmonth
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Barth committed Mar 5, 2024
1 parent c83a952 commit 6c53bd2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 21 deletions.
28 changes: 7 additions & 21 deletions test/test_resolution.jl
Original file line number Diff line number Diff line change
Expand Up @@ -225,32 +225,15 @@ end



daysinmonth(DateTimeAllLeap,2001,2)
@test daysinmonth(DateTimeAllLeap,2001,2) == 29
@test daysinmonth(DateTimeStandard,1582,10) == 21

dt = DateTimeStandard(1582,10,1)
daysinmonth(DateTimeStandard,1582,10)

daysinmonth(dt)

DT = DateTimeStandard
import CFTime: DateTimeStandard, unwrap, _factor, _exponent, _type



#function DateTimeStandard{Period{Int64, Val{1}(), Val{-3}()}, Val{(1970, 1, 1)}()}(y::Int64, m::Int64, d::Int64)

Delta = Dates.Year(1) + Dates.Day(1)
@test DateTimeStandard(2000,1,1) + Delta == DateTimeStandard(2001,1,2)

@test daysinmonth(DateTimeStandard(1582,10,1)) == 21

dt = DateTimeStandard(1582,10,1)

T = typeof(dt.instant)
Torigintuple = Val{(1970, 1, 1)}()

args = (1582,10,1)

parse(DateTimeNoLeap,"1999-12-05", dateformat"yyyy-mm-dd")

@test parse(DateTimeNoLeap,"1999-12-05", dateformat"yyyy-mm-dd") == DateTimeNoLeap(1999,12,05)

dt = DateTimeStandard(1,"nanoseconds since 1999-12-31T23:59:59.999999999")
Expand Down Expand Up @@ -333,3 +316,6 @@ dt = CFTime.timedecode([0,1],"years since 2000-01-01T00:00:00", prefer_datetime

dt = CFTime.timedecode([0,1],"months since 2000-01-01T00:00:00", prefer_datetime = false)
@test Dates.value(Dates.Millisecond(dt[2] - dt[1])) == CFTime.SOLAR_YEAR ÷ 12

dt = CFTime.timedecode(1,"days since 2000-01-01T00:00:00", prefer_datetime = false)
@test Dates.value(dt) == dt.instant.duration
12 changes: 12 additions & 0 deletions test/test_time.jl
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,19 @@ end
[DateTime(2000,1,1), missing]
)

@test isequal(
timedecode(DateTime,[0,missing], "seconds since 2000-01-01 00:00:00"),
[DateTime(2000,1,1), missing]
)

@test isequal(
timeencode([DateTime(2000,1,1), missing], "seconds since 2000-01-01 00:00:00", "proleptic_gregorian"),
[0.0,missing]
)

@test timeencode(DateTime(2000,1,2), "days since 2000-01-01 00:00:00") == 1


timedecode(0, "seconds since 2000-01-01 00:00:00", "proleptic_gregorian"),

@test_logs (:warn,r".*converted.*") @test_throws InexactError convert(DateTime,DateTimeStandard(2000,1,1,0,0,0,0,1,units = :microsecond))

0 comments on commit 6c53bd2

Please sign in to comment.