Upgrade time usage for crystal 0.25.0 (#34)

This commit is contained in:
Brian J. Cardiff 2018-06-18 10:26:32 +02:00 committed by GitHub
parent 13916070e0
commit c1f214d695
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 5 deletions

View file

@ -3,4 +3,7 @@ require "./sqlite3/**"
module SQLite3
DATE_FORMAT = "%F %H:%M:%S.%L"
# :nodoc:
TIME_ZONE = Time::Location::UTC
end

View file

@ -64,11 +64,11 @@ class SQLite3::ResultSet < DB::ResultSet
end
def read(t : Time.class) : Time
Time.parse read(String), SQLite3::DATE_FORMAT
Time.parse read(String), SQLite3::DATE_FORMAT, location: SQLite3::TIME_ZONE
end
def read(t : Time?.class) : Time?
read(String?).try { |v| Time.parse(v, SQLite3::DATE_FORMAT) }
read(String?).try { |v| Time.parse(v, SQLite3::DATE_FORMAT, location: SQLite3::TIME_ZONE) }
end
def read(t : Bool.class) : Bool

View file

@ -70,7 +70,7 @@ class SQLite3::Statement < DB::Statement
end
private def bind_arg(index, value : Time)
bind_arg(index, value.to_s(SQLite3::DATE_FORMAT))
bind_arg(index, value.in(SQLite3::TIME_ZONE).to_s(SQLite3::DATE_FORMAT))
end
private def bind_arg(index, value)