Use the tidFromDate() function from lib/dbutils.js