dohutil 0.2.13 → 0.2.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/dohutil/core_ext/date.rb +11 -0
- data/lib/dohutil/core_ext/datewithtime.rb +0 -10
- data/lib/dohutil/core_ext/random.rb +8 -0
- data/lib/dohutil/current_date.rb +1 -1
- metadata +14 -21
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ab1cdc5f0dc7ef1e62bfe0e7e21b8f71ef80f81e
|
4
|
+
data.tar.gz: a1df1a39ac5e4aba7ffd2ad2bb032df1f167c73a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ea2dc5c47c49461859ab39c0aa19b1f2664db13ec17de8562534386c6e5c29c7d14dc8ae4748648f597636aefd530e0645bd8f95bde3929d12e4bda8f29d06db
|
7
|
+
data.tar.gz: 22c516d08bda2d33f562e2947c0c8cca32b19c2056ba72ba0939c662ba7252b280a8c23c5b4f9cf8ab4136cd8d56899c7de610ac20679e40259e64a9da9a5be0
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'date'
|
2
|
+
require 'time'
|
2
3
|
|
3
4
|
class Date
|
4
5
|
def self.days_in_month(year, month)
|
@@ -12,4 +13,14 @@ class Date
|
|
12
13
|
def make_datetime(hour = 0, minute = 0, second = 0, offset = 0)
|
13
14
|
DateTime.new(year, month, mday, hour, minute, second, offset)
|
14
15
|
end
|
16
|
+
|
17
|
+
def make_local_datetime(hour = 0, minute = 0, second = 0)
|
18
|
+
DateTime.local(year, month, mday, hour, minute, second)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class DateTime
|
23
|
+
def self.local(year, month, day, hour = 0, minute = 0, second = 0)
|
24
|
+
Time.local(year, month, day, hour, minute, second).to_datetime
|
25
|
+
end
|
15
26
|
end
|
@@ -7,11 +7,6 @@ class DateTime
|
|
7
7
|
SECONDS_IN_DAY = Rational(1, 60 * 60 * 24)
|
8
8
|
end
|
9
9
|
|
10
|
-
def self.zow
|
11
|
-
obj = now
|
12
|
-
new(obj.year, obj.month, obj.mday, obj.hour, obj.min, obj.sec, 0)
|
13
|
-
end
|
14
|
-
|
15
10
|
def self.seconds_to_days(seconds)
|
16
11
|
seconds.to_f * SECONDS_IN_DAY #.to_f
|
17
12
|
end
|
@@ -31,11 +26,6 @@ class DateTime
|
|
31
26
|
end
|
32
27
|
|
33
28
|
class Time
|
34
|
-
def self.zow
|
35
|
-
obj = now
|
36
|
-
new(obj.year, obj.month, obj.mday, obj.hour, obj.min, obj.sec, 0)
|
37
|
-
end
|
38
|
-
|
39
29
|
def next_second(n = 1)
|
40
30
|
self + n
|
41
31
|
end
|
data/lib/dohutil/current_date.rb
CHANGED
@@ -9,7 +9,7 @@ def current_date(dflt = Date.today)
|
|
9
9
|
@current_date_stack.last.to_date
|
10
10
|
end
|
11
11
|
|
12
|
-
def current_datetime(dflt = DateTime.
|
12
|
+
def current_datetime(dflt = DateTime.now)
|
13
13
|
return dflt if @current_date_stack.empty?
|
14
14
|
cdo = @current_date_stack.last
|
15
15
|
return cdo if cdo.respond_to?(:hour)
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dohutil
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.14
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Makani Mason
|
@@ -10,54 +9,48 @@ authors:
|
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date: 2013-
|
12
|
+
date: 2013-06-12 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: dohroot
|
17
16
|
requirement: !ruby/object:Gem::Requirement
|
18
|
-
none: false
|
19
17
|
requirements:
|
20
|
-
- -
|
18
|
+
- - '>='
|
21
19
|
- !ruby/object:Gem::Version
|
22
20
|
version: 0.1.2
|
23
21
|
type: :runtime
|
24
22
|
prerelease: false
|
25
23
|
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
none: false
|
27
24
|
requirements:
|
28
|
-
- -
|
25
|
+
- - '>='
|
29
26
|
- !ruby/object:Gem::Version
|
30
27
|
version: 0.1.2
|
31
28
|
- !ruby/object:Gem::Dependency
|
32
29
|
name: highline
|
33
30
|
requirement: !ruby/object:Gem::Requirement
|
34
|
-
none: false
|
35
31
|
requirements:
|
36
|
-
- -
|
32
|
+
- - '>='
|
37
33
|
- !ruby/object:Gem::Version
|
38
34
|
version: 1.6.13
|
39
35
|
type: :runtime
|
40
36
|
prerelease: false
|
41
37
|
version_requirements: !ruby/object:Gem::Requirement
|
42
|
-
none: false
|
43
38
|
requirements:
|
44
|
-
- -
|
39
|
+
- - '>='
|
45
40
|
- !ruby/object:Gem::Version
|
46
41
|
version: 1.6.13
|
47
42
|
- !ruby/object:Gem::Dependency
|
48
43
|
name: dohtest
|
49
44
|
requirement: !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
45
|
requirements:
|
52
|
-
- -
|
46
|
+
- - '>='
|
53
47
|
- !ruby/object:Gem::Version
|
54
48
|
version: 0.1.19
|
55
49
|
type: :development
|
56
50
|
prerelease: false
|
57
51
|
version_requirements: !ruby/object:Gem::Requirement
|
58
|
-
none: false
|
59
52
|
requirements:
|
60
|
-
- -
|
53
|
+
- - '>='
|
61
54
|
- !ruby/object:Gem::Version
|
62
55
|
version: 0.1.19
|
63
56
|
description: Tiny utilities, packaged together so they don't each have their own gem.
|
@@ -84,6 +77,7 @@ files:
|
|
84
77
|
- lib/dohutil/core_ext/force_deep_copy.rb
|
85
78
|
- lib/dohutil/core_ext/hash.rb
|
86
79
|
- lib/dohutil/core_ext/inspect.rb
|
80
|
+
- lib/dohutil/core_ext/random.rb
|
87
81
|
- lib/dohutil/core_ext/string.rb
|
88
82
|
- lib/dohutil/current_date.rb
|
89
83
|
- lib/dohutil/env.rb
|
@@ -98,27 +92,26 @@ files:
|
|
98
92
|
homepage: https://github.com/atpsoft/dohutil
|
99
93
|
licenses:
|
100
94
|
- MIT
|
95
|
+
metadata: {}
|
101
96
|
post_install_message:
|
102
97
|
rdoc_options: []
|
103
98
|
require_paths:
|
104
99
|
- lib
|
105
100
|
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
-
none: false
|
107
101
|
requirements:
|
108
|
-
- -
|
102
|
+
- - '>='
|
109
103
|
- !ruby/object:Gem::Version
|
110
104
|
version: 1.9.3
|
111
105
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
|
-
none: false
|
113
106
|
requirements:
|
114
|
-
- -
|
107
|
+
- - '>='
|
115
108
|
- !ruby/object:Gem::Version
|
116
109
|
version: '0'
|
117
110
|
requirements: []
|
118
111
|
rubyforge_project:
|
119
|
-
rubygems_version:
|
112
|
+
rubygems_version: 2.0.2
|
120
113
|
signing_key:
|
121
|
-
specification_version:
|
114
|
+
specification_version: 4
|
122
115
|
summary: assorted tiny utilities
|
123
116
|
test_files:
|
124
117
|
- test/core_ext/bigdecimal.dt.rb
|