 
 dbTypeToJsType = {
     varchar: 'string'
-    datetime: 'date'
+    datetime: 'datetime'
     int: 'number'
 }
 

#
# The schema API however ALWAYS WORKS WITH NAMES to ensure sanity. Names are immutable.

class JsDate
    padNumber = (number, l = 2) ->
        r = String(number)
        r = "0#{r}" while r.length < l
        return r

    constructor: (@value) ->

    toString: () ->
        dt = new Date(@value)
        y = padNumber(dt.getFullYear(),4)
        m = padNumber(dt.getMonth() + 1)
        d = padNumber(dt.getDate())
        h = padNumber(dt.getHours())
        n = padNumber(dt.getMinutes())
        s = padNumber(dt.getSeconds())
        return "'#{y}-#{m}-#{d} #{h}:#{n}:#{s}'"

jsTypes = {

        numeric: false
        string: true

    datetime:
        matchesType: _.isDate
        # MUST: beef date conversion way up
        convert: JsDateTime
        name: 'Date'
        numeric: false
}
