On the origins of the Te Deum: http://www.newadvent.org/cathen/14468c.htm

As for the issue of dies being masculine or feminine, the Romans do not seem to have been consistent about this. Although, as you say when dies means a particular appointed day in the singular it is feminine, this is not a hard and fast rule -- there are plenty of examples of it still being masculine. See the entry in the Latin dictionary on Perseus:
http://makeashorterlink.com/?H30423FE5

Bingley


Bingley