BAMPFA-79: Implement scalar date computation. Also some refactoring.