Based on a reply on github stating that the problem is with how the Dual handles mod and rem, I tried floor division to get the remainder, and that works:
#+begin_src julia
function f(t)
times = t ÷ 1
t = t - times
sin(pi * 2 * (t ))^2 * (t < 0.5)
end
#+end_src
#+RESULTS:
: f (generic function with 1 method)
#+begin_src julia
ForwardDiff.derivative(f, 1)
#+end_src
#+RESULTS:
: 0.0
#+begin_src julia
derivative(f, 1)
#+end_src
#+RESULTS:
: 0.00011952987976706194