Can I use Ruby to call the timeline from the SketchUp shadow setting function?

shadowinfo["ShadowTime"] returns a standard Ruby Time class object.
It has instance methods to get all that you ask for.

The module name was just a temporary namespace for the example. You would name it something else, or more likely add the example methods to your own extension module.