time_of_day_attr 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -23
- data/lib/time_of_day_attr/version.rb +1 -1
- data/lib/time_of_day_attr.rb +1 -0
- data/test/time_of_day_attr_test.rb +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89598098237c1f05d5e43ddd93cab45dd9dac493
|
4
|
+
data.tar.gz: 8d777ae07c21629d8ede0408356e864295a5ab83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 08051c9d5b9c057fcfed48111cca292b6695815383dd12eb818931f8130fd0805b1621b6961d59d174c215204e516d0fa02a0744079d6f9d1da9c9ac910cb652
|
7
|
+
data.tar.gz: 8b3f4cce1f11cb6207aee0d3485774023ce3e25fb4827b28b6a1a82df01789f724d6ef54506cc18cc0025925b59fee7161440f0bb59a901c0aa4bb4bd479db01
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# time_of_day_attr
|
2
|
-
[![Gem Version](https://badge.fury.io/rb/time_of_day_attr.png)](http://badge.fury.io/rb/time_of_day_attr) [![Code Climate](https://codeclimate.com/github/clemenst/time_of_day_attr.png)](https://codeclimate.com/github/clemenst/time_of_day_attr)
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/time_of_day_attr.png)](http://badge.fury.io/rb/time_of_day_attr) [![Code Climate](https://codeclimate.com/github/clemenst/time_of_day_attr.png)](https://codeclimate.com/github/clemenst/time_of_day_attr) [![License](https://img.shields.io/npm/l/express.svg?style=flat)](http://clemenst.mit-license.org)
|
3
3
|
|
4
4
|
Convert time of day to seconds since midnight and back.
|
5
5
|
|
@@ -86,25 +86,4 @@ To get a text field with the converted value:
|
|
86
86
|
|
87
87
|
## License
|
88
88
|
|
89
|
-
|
90
|
-
|
91
|
-
Copyright 2013 by Clemens Teichmann
|
92
|
-
|
93
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
94
|
-
a copy of this software and associated documentation files (the
|
95
|
-
"Software"), to deal in the Software without restriction, including
|
96
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
97
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
98
|
-
permit persons to whom the Software is furnished to do so, subject to
|
99
|
-
the following conditions:
|
100
|
-
|
101
|
-
The above copyright notice and this permission notice shall be
|
102
|
-
included in all copies or substantial portions of the Software.
|
103
|
-
|
104
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
105
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
106
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
107
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
108
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
109
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
110
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
89
|
+
[MIT](http://clemenst.mit-license.org)
|
data/lib/time_of_day_attr.rb
CHANGED
@@ -17,6 +17,7 @@ module TimeOfDayAttr
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def localize(value, options = {})
|
20
|
+
return value unless value.respond_to?(:seconds)
|
20
21
|
format = options[:format] || :default
|
21
22
|
format = translate_format(format) if format.is_a?(Symbol)
|
22
23
|
time = Time.now.at_midnight + value.seconds
|
@@ -24,6 +24,10 @@ class TimeOfDayAttrTest < ActiveSupport::TestCase
|
|
24
24
|
assert_equal ' 0', TimeOfDayAttr.localize(86400, omit_minutes_at_full_hour: true)
|
25
25
|
end
|
26
26
|
|
27
|
+
test 'localizing nil should return nil' do
|
28
|
+
assert_nil TimeOfDayAttr.localize(nil)
|
29
|
+
end
|
30
|
+
|
27
31
|
test 'time of day attr setter should delocalize value' do
|
28
32
|
business_hour = BusinessHour.new(opening: '9:00', closing: '17:00')
|
29
33
|
assert_equal 32400, business_hour.opening
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: time_of_day_attr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Clemens Teichmann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|