Added datetime builtins to policy engine

Also fixed a number of bugs while testing.
Also expanded tests.

Change-Id: I72137f53028ed09bbcf74c98bab620d41296ec49