just-time-picker 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.rdoc CHANGED
@@ -135,6 +135,10 @@ This code is licensed under GPLv3[http://www.gnu.org/licenses/gpl.html].
135
135
 
136
136
  == ChangeLog
137
137
 
138
+ === 0.0.2 (March 2, 2013)
139
+
140
+ * Added xmlschema and iso8601 methods to Time class ({Marcin Lewandowski}[https://github.com/saepia])
141
+
138
142
  === 0.0.1 (February 23, 2013)
139
143
 
140
144
  * Initial release based on {just-datetime-picker}[https://github.com/saepia/just-datetime-picker] 0.0.6 ({Marcin Lewandowski}[https://github.com/saepia])
@@ -11,7 +11,7 @@ Gem::Specification.new do |gem|
11
11
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
12
12
  gem.name = "just-time-picker"
13
13
  gem.require_paths = ["lib"]
14
- gem.version = '0.0.1'
14
+ gem.version = '0.0.2'
15
15
  gem.add_dependency 'formtastic', '>= 2.0.0'
16
16
  gem.add_dependency 'activeadmin', '>= 0.4.4'
17
17
  end
@@ -3,6 +3,7 @@ module Just
3
3
  module DatabaseAbstraction
4
4
  module DataTypes
5
5
  class Time
6
+
6
7
  def initialize(original_time)
7
8
  if original_time.nil?
8
9
  @original_time = nil
@@ -25,11 +26,33 @@ module Just
25
26
  @original_time.min
26
27
  end
27
28
 
28
- def to_s
29
+ def to_s(include_seconds = false)
29
30
  return nil if @original_time.nil?
30
31
 
31
- "#{sprintf("%02d", hour)}:#{sprintf("%02d", min)}"
32
+ if include_seconds
33
+ "#{sprintf("%02d", hour)}:#{sprintf("%02d", min)}:00"
34
+ else
35
+ "#{sprintf("%02d", hour)}:#{sprintf("%02d", min)}"
36
+ end
32
37
  end
38
+
39
+ def xmlschema(fraction_digits = 0)
40
+ if fraction_digits == 0
41
+ to_s true
42
+ else
43
+ "#{to_s(true)}.#{"0" * fraction_digits}"
44
+ end
45
+ end
46
+
47
+ alias :iso8601 :xmlschema
48
+
49
+ def as_json
50
+ return nil if @original_time.nil?
51
+
52
+ to_s true
53
+ end
54
+
55
+
33
56
  end
34
57
  end
35
58
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: just-time-picker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-02-23 00:00:00.000000000 Z
13
+ date: 2013-03-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: formtastic