Skip to content

Commit

Permalink
set(dates): relax type signature
Browse files Browse the repository at this point in the history
  • Loading branch information
aplavin committed Aug 25, 2024
1 parent 9ef4598 commit a2b0d82
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions ext/AccessorsDatesExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ set(x::Time, ::typeof(Dates.value), y) = @set x.instant.value = y
set(x::Date, ::typeof(year), y) = Date(y, month(x), day(x))
set(x::Date, ::typeof(month), y) = Date(year(x), y, day(x))
set(x::Date, ::typeof(day), y) = Date(year(x), month(x), y)
set(x::Date, ::typeof(yearmonth), y::NTuple{2}) = Date(y..., day(x))
set(x::Date, ::typeof(monthday), y::NTuple{2}) = Date(year(x), y...)
set(x::Date, ::typeof(yearmonthday), y::NTuple{3}) = Date(y...)
set(x::Date, ::typeof(yearmonth), y::NTuple{2, Any}) = Date(y..., day(x))
set(x::Date, ::typeof(monthday), y::NTuple{2, Any}) = Date(year(x), y...)
set(x::Date, ::typeof(yearmonthday), y::NTuple{3, Any}) = Date(y...)
set(x::Date, ::typeof(dayofweek), y) = firstdayofweek(x) + Day(y - 1)

set(x::Time, ::typeof(hour), y) = Time(y, minute(x), second(x), millisecond(x), microsecond(x), nanosecond(x))
Expand Down
6 changes: 3 additions & 3 deletions test/test_functionlenses.jl
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,9 @@ end
test_getset_laws(lens, Time(1, 2, 3, 4, 5, 6), rand(0:23), rand(0:23))
end
@testset for x in [DateTime(2020, 1, 2, 3, 4, 5, 6), Date(2020, 1, 2)]
test_getset_laws(yearmonth, x, (rand(1:5000), rand(1:12)), (rand(1:5000), rand(1:12)))
test_getset_laws(monthday, x, (rand(1:12), rand(1:28)), (rand(1:12), rand(1:28)))
test_getset_laws(yearmonthday, x, (rand(1:5000), rand(1:12), rand(1:28)), (rand(1:5000), rand(1:12), rand(1:28)))
test_getset_laws(yearmonth, x, (rand(1:5000), rand(1:12) |> Int8), (rand(1:5000), rand(1:12)))
test_getset_laws(monthday, x, (rand(1:12), rand(1:28) |> Int8), (rand(1:12), rand(1:28)))
test_getset_laws(yearmonthday, x, (rand(1:5000), rand(1:12) |> Int8, rand(1:28)), (rand(1:5000), rand(1:12), rand(1:28)))
end

@testset for x in [DateTime(2020, 1, 2, 3, 4, 5, 6), Date(2020, 1, 2), Time(1, 2, 3, 4, 5, 6)]
Expand Down

0 comments on commit a2b0d82

Please sign in to comment.