So after some struggling i ended up with following solution:
So with input below I would get
Please pay attention to the fact that I even took care of supporting formatting date(time)s and numbers with my implementation.
Another more complex example
will result in