 
 fileprivate let formatter = DateFormatter()
 
-/// returns a formatted date string
-/// optionally in a given abbreviated timezone like "UTC"
-fileprivate func formatDate(_ dateFormat: String, timeZone: String = "") -> String {
+/// returns a formatted date string of a given date
+/// on default it uses the abbreviated timezone "UTC"
+fileprivate func formatDate(_ date: Date, format: String, timezone: String = "UTC") -> String {
     let formatter = DateFormatter()
 
-    if !timeZone.isEmpty {
-        formatter.timeZone = TimeZone(abbreviation: timeZone)
+    if !timezone.isEmpty {
+        formatter.timeZone = TimeZone(abbreviation: timezone)
     }
-    formatter.dateFormat = dateFormat
+    formatter.dateFormat = format
 
-    let dateStr = formatter.string(from: Date())
+    let dateStr = formatter.string(from: date)
     return dateStr
 }

        let myDouble = rows[0]["my_double"] as? Float
        XCTAssertEqual(myDouble!, 456.789)

        // timestamp to int
        let myTS = rows[0]["my_ts"] as? Date
        XCTAssertNotNil(myTS)

        // date to int
        let myDate = rows[0]["my_date"] as? Date
        XCTAssertNotNil(myDate)

        // conversion from integer to string returns nil
        let idString = rows[0]["id"] as? String

        sql += ", my_varchar VARCHAR(3) default 'abc', my_char CHAR(1) default 'x', my_null_text TEXT default null"
        sql += ", my_real REAL default 123.456, my_double DOUBLE PRECISION default 456.789"
        // sql += ", row_to_json(row(1,'foo'))"
        sql += ", my_date DATE default (now() at time zone 'utc')"
        sql += ", my_ts TIMESTAMP default (now() at time zone 'utc')"
        sql += ");"
        res = try! db.query(sql)
        XCTAssertNotNil(res)
    }

