dohutil 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/doh/core_ext/datewithtime.rb +17 -22
- data/lib/doh/current_date.rb +2 -2
- metadata +7 -8
- data/lib/doh/core_ext/utc.rb +0 -19
@@ -1,30 +1,14 @@
|
|
1
1
|
require 'date'
|
2
2
|
require 'time'
|
3
3
|
|
4
|
-
# these are sets of methods to make DateTime & Time objects more interchangeable
|
5
|
-
# they are not comprehensive, nor exact - for example, this DateTime utc method does not modify the receiver, whereas the Time utc method does
|
6
|
-
# they simply provide good enough compatibility for what I've encountered so far
|
7
|
-
module MakeDateTimeLikeTime
|
8
|
-
def utc
|
9
|
-
new_offset
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
module MakeTimeLikeDateTime
|
14
|
-
def next_second(n = 1)
|
15
|
-
self + n
|
16
|
-
end
|
17
|
-
|
18
|
-
def prev_second(n = 1)
|
19
|
-
self - n
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
4
|
class DateTime
|
24
|
-
include MakeDateTimeLikeTime
|
25
|
-
|
26
5
|
DOHRUBY_SECONDS_IN_DAY = (24 * 60 * 60).freeze
|
27
6
|
|
7
|
+
def self.zow
|
8
|
+
obj = now
|
9
|
+
new(obj.year, obj.month, obj.mday, obj.hour, obj.min, obj.sec, 0)
|
10
|
+
end
|
11
|
+
|
28
12
|
def self.seconds_to_days(seconds)
|
29
13
|
seconds.to_f / DOHRUBY_SECONDS_IN_DAY.to_f
|
30
14
|
end
|
@@ -44,5 +28,16 @@ class DateTime
|
|
44
28
|
end
|
45
29
|
|
46
30
|
class Time
|
47
|
-
|
31
|
+
def self.zow
|
32
|
+
obj = now
|
33
|
+
new(obj.year, obj.month, obj.mday, obj.hour, obj.min, obj.sec, 0)
|
34
|
+
end
|
35
|
+
|
36
|
+
def next_second(n = 1)
|
37
|
+
self + n
|
38
|
+
end
|
39
|
+
|
40
|
+
def prev_second(n = 1)
|
41
|
+
self - n
|
42
|
+
end
|
48
43
|
end
|
data/lib/doh/current_date.rb
CHANGED
@@ -4,12 +4,12 @@ module Doh
|
|
4
4
|
|
5
5
|
@@current_date_objs = []
|
6
6
|
|
7
|
-
def self.current_date(dflt = Date.
|
7
|
+
def self.current_date(dflt = Date.today)
|
8
8
|
return dflt if @@current_date_objs.empty?
|
9
9
|
@@current_date_objs.last.to_date
|
10
10
|
end
|
11
11
|
|
12
|
-
def self.current_datetime(dflt = DateTime.
|
12
|
+
def self.current_datetime(dflt = DateTime.zow)
|
13
13
|
return dflt if @@current_date_objs.empty?
|
14
14
|
cdo = @@current_date_objs.last
|
15
15
|
return cdo if cdo.respond_to?(:hour)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dohutil
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-03-
|
13
|
+
date: 2012-03-30 00:00:00.000000000Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: dohroot
|
17
|
-
requirement: &
|
17
|
+
requirement: &70168643920460 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,18 +22,18 @@ dependencies:
|
|
22
22
|
version: 0.1.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70168643920460
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: dohtest
|
28
|
-
requirement: &
|
28
|
+
requirement: &70168643919780 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.1.
|
33
|
+
version: 0.1.8
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *70168643919780
|
37
37
|
description: Tiny utilities, packaged together so they don't each have their own gem.
|
38
38
|
email:
|
39
39
|
- devinfo@atpsoft.com
|
@@ -55,7 +55,6 @@ files:
|
|
55
55
|
- lib/doh/core_ext/hash.rb
|
56
56
|
- lib/doh/core_ext/inspect.rb
|
57
57
|
- lib/doh/core_ext/string.rb
|
58
|
-
- lib/doh/core_ext/utc.rb
|
59
58
|
- lib/doh/current_date.rb
|
60
59
|
- lib/doh/env.rb
|
61
60
|
- lib/doh/http_helper.rb
|
data/lib/doh/core_ext/utc.rb
DELETED