I don't need to know about pkg TYVM
Explicitly convert the timestamp back to an integer

This appears to provide some extra precision.
Catch a few things that might cause EINVAL

Better to tell people what's going wrong, instead of just dropping
a native errno on them and letting them guess.