date_time_precision 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6df7946e71f0bd5f715eb269eb11473a223ab8c8
4
+ data.tar.gz: 53069451ea0a2048520a739035bb2969a8929279
5
+ SHA512:
6
+ metadata.gz: dd7cba4355d9e59ec183f2da402c4a643dcb88d01d189a1a1437ef8ef432452161e2ad6c992c3aa369c925956a2ec2fe8dc0ef79769da11e2fba0e742e6d774b
7
+ data.tar.gz: 12ba91418764b74d764b65a1e66a42120e5f4ea41e0c230b7960e1ffab2a7dc13c485fa6ecdb0ffacd214b3329556aab65b3f2dd6b4fe06775ded1b821fe89e0
data/README.md CHANGED
@@ -6,8 +6,8 @@ Unfortunately, Ruby's built-in Date, Time, and DateTime classes do not keep trac
6
6
  For example:
7
7
 
8
8
  ```ruby
9
- Date.new.to_s => "-4712-01-01"
10
- Date.new(2000).to_s => "2000-01-01"
9
+ Date.new.to_s # => "-4712-01-01"
10
+ Date.new(2000).to_s # => "2000-01-01"
11
11
  ```
12
12
 
13
13
  There is no way to tell the difference between January 1, 2000 and a Date where only the year 2000 was known.
@@ -46,7 +46,8 @@ The gem adds the following instance methods to Date, Time, and/or DateTime:
46
46
 
47
47
  ## Formats
48
48
 
49
- It is useful to convert the various time classes into other formats that preserve the precision. The currently supported formats are Hash and JSON.
49
+ It is useful to convert the various time classes into other formats that preserve the precision.
50
+ The currently supported formats are Hash, JSON, and ISO 8601.
50
51
 
51
52
  Examples:
52
53
 
@@ -55,14 +56,14 @@ require 'date_time_precision/format/hash'
55
56
 
56
57
  date = Date.new(2000, 10)
57
58
  hash = date.to_h
58
- => {:year=>2000, :mon=>10}
59
+ # => {:year=>2000, :mon=>10}
59
60
 
60
61
  hash.to_date.precision
61
- => 2
62
+ # => 2
62
63
 
63
64
  birthday = Date.new(nil, 11, 12)
64
65
  birthday.to_h
65
- => {:mon => 11, :day => 12}
66
+ # => {:mon => 11, :day => 12}
66
67
  ```
67
68
 
68
69
  ```ruby
@@ -70,17 +71,17 @@ require 'date_time_precision/format/json'
70
71
 
71
72
  date = Date.new(2000, 10)
72
73
  puts json = date.to_json
73
- => {"year":2000,"mon":10}
74
+ # => {"year":2000,"mon":10}
74
75
 
75
76
  JSON.parse(json).to_date.precision
76
- => 2
77
+ # => 2
77
78
  ```
78
79
 
79
80
  ```ruby
80
81
  require 'date_time_precision/format/iso8601'
81
82
 
82
83
  Date.new(2000, 5).iso8601
83
- => "2000-05"
84
+ # => "2000-05"
84
85
  ```
85
86
 
86
87
  ## Ruby Compatibility
@@ -1,8 +1,10 @@
1
+ module DateTimePrecision
2
+ ISO8601_DATE_FRAGMENTS = %w(%0*d %02d %02d)
3
+ ISO8601_TIME_FRAGMENTS = %w(%02d %02d %02d)
4
+ end
5
+
1
6
  [Date, Time, DateTime].each do |klass|
2
7
  klass.class_eval do
3
- ISO8601_DATE_FRAGMENTS = %w(%0*d %02d %02d)
4
- ISO8601_TIME_FRAGMENTS = %w(%02d %02d %02d)
5
-
6
8
  if method_defined?(:xmlschema)
7
9
  alias_method :xmlschema_without_precision, :xmlschema
8
10
  end
@@ -19,11 +21,11 @@
19
21
  format = ""
20
22
  if precision > DateTimePrecision::NONE
21
23
  # Add date part to format
22
- format << ISO8601_DATE_FRAGMENTS.take([3,self.precision].min).join('-')
24
+ format << DateTimePrecision::ISO8601_DATE_FRAGMENTS.take([3,self.precision].min).join('-')
23
25
  end
24
26
 
25
27
  if precision > DateTimePrecision::DAY
26
- format << "T#{ISO8601_TIME_FRAGMENTS.take(precision - 3).join(':')}"
28
+ format << "T#{DateTimePrecision::ISO8601_TIME_FRAGMENTS.take(precision - 3).join(':')}"
27
29
  end
28
30
 
29
31
  output = sprintf(format, year < 0 ? 5 : 4, *self.fragments)
@@ -1,3 +1,3 @@
1
1
  module DateTimePrecision
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
metadata CHANGED
@@ -1,120 +1,106 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: date_time_precision
3
- version: !ruby/object:Gem::Version
4
- hash: 11
5
- prerelease:
6
- segments:
7
- - 0
8
- - 5
9
- - 0
10
- version: 0.5.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.1
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - David Butler
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2013-03-30 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- version_requirements: &id001 !ruby/object:Gem::Requirement
22
- none: false
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- hash: 3
27
- segments:
28
- - 0
29
- version: "0"
30
- prerelease: false
31
- type: :development
11
+ date: 2013-04-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
32
14
  name: rake
33
- requirement: *id001
34
- - !ruby/object:Gem::Dependency
35
- version_requirements: &id002 !ruby/object:Gem::Requirement
36
- none: false
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- hash: 3
41
- segments:
42
- - 0
43
- version: "0"
44
- prerelease: false
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
45
20
  type: :development
46
- name: rspec
47
- requirement: *id002
48
- - !ruby/object:Gem::Dependency
49
- version_requirements: &id003 !ruby/object:Gem::Requirement
50
- none: false
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- hash: 3
55
- segments:
56
- - 0
57
- version: "0"
58
21
  prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
59
34
  type: :development
60
- name: activesupport
61
- requirement: *id003
62
- - !ruby/object:Gem::Dependency
63
- version_requirements: &id004 !ruby/object:Gem::Requirement
64
- none: false
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- hash: 3
69
- segments:
70
- - 0
71
- version: "0"
72
35
  prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: activesupport
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
73
48
  type: :development
74
- name: json
75
- requirement: *id004
76
- - !ruby/object:Gem::Dependency
77
- version_requirements: &id005 !ruby/object:Gem::Requirement
78
- none: false
79
- requirements:
80
- - - "="
81
- - !ruby/object:Gem::Version
82
- hash: 3
83
- segments:
84
- - 0
85
- - 5
86
- - 4
87
- version: 0.5.4
88
49
  prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: json
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
89
62
  type: :development
90
- name: virtus
91
- requirement: *id005
92
- - !ruby/object:Gem::Dependency
93
- version_requirements: &id006 !ruby/object:Gem::Requirement
94
- none: false
95
- requirements:
96
- - - "="
97
- - !ruby/object:Gem::Version
98
- hash: 29
99
- segments:
100
- - 0
101
- - 0
102
- - 1
103
- version: 0.0.1
104
63
  prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: virtus
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
75
+ version: 0.5.4
105
76
  type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '='
81
+ - !ruby/object:Gem::Version
82
+ version: 0.5.4
83
+ - !ruby/object:Gem::Dependency
106
84
  name: coercible
107
- requirement: *id006
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 0.0.1
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 0.0.1
108
97
  description: Patches Date, Time, and DateTime ruby classes to keep track of precision
109
- email:
98
+ email:
110
99
  - dwbutler@ucla.edu
111
100
  executables: []
112
-
113
101
  extensions: []
114
-
115
102
  extra_rdoc_files: []
116
-
117
- files:
103
+ files:
118
104
  - .gitignore
119
105
  - .travis.yml
120
106
  - Gemfile
@@ -151,38 +137,28 @@ files:
151
137
  - spec/spec_helper.rb
152
138
  homepage: http://github.com/Spokeo/date_time_precision
153
139
  licenses: []
154
-
140
+ metadata: {}
155
141
  post_install_message:
156
142
  rdoc_options: []
157
-
158
- require_paths:
143
+ require_paths:
159
144
  - lib
160
- required_ruby_version: !ruby/object:Gem::Requirement
161
- none: false
162
- requirements:
163
- - - ">="
164
- - !ruby/object:Gem::Version
165
- hash: 3
166
- segments:
167
- - 0
168
- version: "0"
169
- required_rubygems_version: !ruby/object:Gem::Requirement
170
- none: false
171
- requirements:
172
- - - ">="
173
- - !ruby/object:Gem::Version
174
- hash: 3
175
- segments:
176
- - 0
177
- version: "0"
145
+ required_ruby_version: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ required_rubygems_version: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - '>='
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
178
155
  requirements: []
179
-
180
156
  rubyforge_project:
181
- rubygems_version: 1.8.24
157
+ rubygems_version: 2.0.0
182
158
  signing_key:
183
- specification_version: 3
159
+ specification_version: 4
184
160
  summary: Patches Date, Time, and DateTime ruby classes to keep track of precision
185
- test_files:
161
+ test_files:
186
162
  - spec/date_time_precision/active_support_spec.rb
187
163
  - spec/date_time_precision/compatibility_spec.rb
188
164
  - spec/date_time_precision/date_time_precision_spec.rb