pg_json 0.1.28 → 0.1.29

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/pg_json/sequel/pg_json.rb +10 -1
  2. metadata +2 -2
@@ -29,12 +29,14 @@ class Hash
29
29
  v.json_typify!
30
30
  else
31
31
  if !v.nil? && v.is_a?(String)
32
- if v =~ /^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\+[0-9]{4}$/
32
+ self[k] = if v =~ /^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\+([0-9]{4}|[0-9]{2}:[0-9]{2})/
33
33
  DateTime.parse(v).to_time
34
34
  elsif v =~ /^[0-9]{4}-[0-9]{2}-[0-9]{2}$/
35
35
  v.to_date
36
36
  elsif v =~ /^[0-9]{2}:[0-9]{2}:[0-9]{2}$/
37
37
  v.to_time
38
+ else
39
+ v
38
40
  end
39
41
  end
40
42
  end
@@ -100,3 +102,10 @@ module Sequel
100
102
  end
101
103
  end
102
104
  end
105
+
106
+ # h = {:valid_from => "2012-04-21T00:00:00+02:00"}
107
+ #
108
+ # h.json_typify!
109
+
110
+ # puts h.inspect
111
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_json
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.28
4
+ version: 0.1.29
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-22 00:00:00.000000000 Z
12
+ date: 2012-04-23 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: bring basic json support to postgresql
15
15
  email: jan.zimmek@web.de