I found myself needing to add methods::setOldClass("difftime") in
order to also set a coercion method for my class to difftime:
methods::setAs("myClass", "difftime", ...)
And thus avoid the on-load message:
in method for ?coerce? with signature ?"myClass","difftime"?: no
definition for class ?difftime?
I see 10 or so other packages also doing the same [1].
I am wondering, though, since {base} owns this class, if it shouldn't
be registered already? I see inclusions for, e.g., closely-related S3
classes Date and POSIXt [2].
OTOH, I see .OldClassesList hasn't really been edited in 15+ years, so
maybe this approach has lost favor and is better not amended anymore
[3].
(or maybe this is really an r-package-devel question about whether
supporting as(<my class>, "difftime") is actually beneficial...)
Mike C
[1] https://github.com/search?q=org%3Acran%20%2FsetOldClass.*difftime%2F&type=code
[2] https://github.com/r-devel/r-svn/blob/b7850c8cae0956592019c5f8f59e885d3d39ae6f/src/library/methods/R/BasicClasses.R#L550-L552
[3] https://github.com/r-devel/r-svn/blame/b7850c8cae0956592019c5f8f59e885d3d39ae6f/src/library/methods/R/BasicClasses.R#L541-L569