Your stylesheet is missing a version attribute, which (a) is illegal (and should cause a fatal error), and (b) means that we don't know whether you are using XSLT 1.0 or XSLT 2.0. This is relevant because XSLT 2.0 has extensive operations for manipulating dates and times. However, you already seem to be doing this using substring(), so I guess it's 1.0.
I get a rough idea of what you are trying to do, but I don't think I understand it in enough detail to show you the code, or even suggest an algorithm. Also I'm really not convinced that using tables is the right way to do this kind of thing - wouldn't SVG be more suitable?
Try producing a simplified version of the problem: simplify the input and show is the desired HTML output.
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference