core :: Text :: to_sql_date_string
self
into an escaped string for SQLiteself
must be composed of 1 to 3 integers separated by '-'.
An incompatible format will result in an invalid date string.
assert "2016-5-1".to_sql_date_string == "'2016-05-01'"
assert "2016".to_sql_date_string == "'2016-01-01'"
# Format the date represented by `self` into an escaped string for SQLite
#
# `self` must be composed of 1 to 3 integers separated by '-'.
# An incompatible format will result in an invalid date string.
#
# assert "2016-5-1".to_sql_date_string == "'2016-05-01'"
# assert "2016".to_sql_date_string == "'2016-01-01'"
fun to_sql_date_string: String
do
var parts = self.split("-")
for i in [parts.length .. 3[ do parts[i] = "1"
var year = parts[0].justify(4, 1.0, '0')
var month = parts[1].justify(2, 1.0, '0')
var day = parts[2].justify(2, 1.0, '0')
return "{year}-{month}-{day}".to_sql_string
end
lib/sqlite3/sqlite3.nit:333,2--349,4