We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
require 'time'
1 parent 84c7122 commit bf952c9Copy full SHA for bf952c9
lib/db/postgres/native/types.rb
@@ -99,12 +99,16 @@ def initialize(name = "TIMESTAMP")
99
attr :name
100
101
def parse(string)
102
- if match = string.match(/(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)([\+\-].*)?/)
103
- parts = match.captures
104
- parts[6] ||= "UTC"
105
-
106
- return Time.new(*parts)
+ return nil unless match = string.match(/\A(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+(?:\.\d+)?)([-+].*)?\z/)
+ parts = match.captures
+ parts[5] = BigDecimal(parts[5])
+ if parts[6].nil?
+ parts[6] = '+00:00'
107
+ elsif /^[-+]\d\d$/ === parts[6]
108
+ parts[6] += ':00'
109
end
110
+
111
+ Time.new(*parts)
112
113
114
0 commit comments