mirror of
https://gitea.invidious.io/iv-org/shard-crystal-sqlite3.git
synced 2024-08-15 00:53:26 +00:00
Upgrade time usage for crystal 0.25.0
This commit is contained in:
parent
13916070e0
commit
7d2ed0e8eb
4 changed files with 9 additions and 5 deletions
|
@ -33,8 +33,9 @@ DB::DriverSpecs(DB::Any).run do
|
||||||
sample_value "hello", "text", "'hello'"
|
sample_value "hello", "text", "'hello'"
|
||||||
sample_value 1.5_f32, "float", "1.5", type_safe_value: false
|
sample_value 1.5_f32, "float", "1.5", type_safe_value: false
|
||||||
sample_value 1.5, "float", "1.5"
|
sample_value 1.5, "float", "1.5"
|
||||||
sample_value Time.new(2016, 2, 15), "text", "'2016-02-15 00:00:00.000'", type_safe_value: false
|
sample_value Time.utc(2016, 2, 15), "text", "'2016-02-15 00:00:00.000'", type_safe_value: false
|
||||||
sample_value Time.new(2016, 2, 15, 10, 15, 30), "text", "'2016-02-15 10:15:30.000'", type_safe_value: false
|
sample_value Time.utc(2016, 2, 15, 10, 15, 30), "text", "'2016-02-15 10:15:30.000'", type_safe_value: false
|
||||||
|
sample_value Time.new(2016, 2, 15, 7, 15, 30, location: Time::Location.fixed("fixed", -3*3600)), "text", "'2016-02-15 10:15:30.000'", type_safe_value: false
|
||||||
|
|
||||||
ary = UInt8[0x53, 0x51, 0x4C, 0x69, 0x74, 0x65]
|
ary = UInt8[0x53, 0x51, 0x4C, 0x69, 0x74, 0x65]
|
||||||
sample_value Bytes.new(ary.to_unsafe, ary.size), "blob", "X'53514C697465'" # , type_safe_value: false
|
sample_value Bytes.new(ary.to_unsafe, ary.size), "blob", "X'53514C697465'" # , type_safe_value: false
|
||||||
|
|
|
@ -3,4 +3,7 @@ require "./sqlite3/**"
|
||||||
|
|
||||||
module SQLite3
|
module SQLite3
|
||||||
DATE_FORMAT = "%F %H:%M:%S.%L"
|
DATE_FORMAT = "%F %H:%M:%S.%L"
|
||||||
|
|
||||||
|
# :nodoc:
|
||||||
|
TIME_ZONE = Time::Location::UTC
|
||||||
end
|
end
|
||||||
|
|
|
@ -64,11 +64,11 @@ class SQLite3::ResultSet < DB::ResultSet
|
||||||
end
|
end
|
||||||
|
|
||||||
def read(t : Time.class) : Time
|
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
|
end
|
||||||
|
|
||||||
def read(t : Time?.class) : Time?
|
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
|
end
|
||||||
|
|
||||||
def read(t : Bool.class) : Bool
|
def read(t : Bool.class) : Bool
|
||||||
|
|
|
@ -70,7 +70,7 @@ class SQLite3::Statement < DB::Statement
|
||||||
end
|
end
|
||||||
|
|
||||||
private def bind_arg(index, value : Time)
|
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
|
end
|
||||||
|
|
||||||
private def bind_arg(index, value)
|
private def bind_arg(index, value)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue