buzztools 0.0.11 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/buzztools/extend_string.rb +2 -2
- data/lib/buzztools/extend_time.rb +19 -3
- data/lib/buzztools/version.rb +1 -1
- 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: 87130a8f6f70059943edc9adda62d2c77e1542f7
|
4
|
+
data.tar.gz: 32976f3798c1a36cf9b96cd197de890d8fb4afd2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b98fc7ea7b7565974983feddecb1a4bbf9d56bec54b8216f16060d8ab7f30c638d1455980cb3e85e0c5e7ee0ac40ba97a4dbef73b1956251593df6800c0f7a4
|
7
|
+
data.tar.gz: ae0952b532029a44988c6ff30918e07baa7f328d1b0fe0d4ccb5ae38e722c636154a3ee352cec9969fff5a20afe06cc532a8e63a9e02cd769a1953e0f9d2ff10
|
@@ -86,7 +86,7 @@ String.class_eval do
|
|
86
86
|
deprefix!(aValue,self.clone)
|
87
87
|
end
|
88
88
|
|
89
|
-
def desuffix!(aString
|
89
|
+
def desuffix!(aSuffix=$/,aString=self)
|
90
90
|
if aString[-aSuffix.length,aSuffix.length] == aSuffix
|
91
91
|
aString[-aSuffix.length,aSuffix.length] = ''
|
92
92
|
return aString
|
@@ -96,7 +96,7 @@ String.class_eval do
|
|
96
96
|
end
|
97
97
|
|
98
98
|
def desuffix(aValue=$/)
|
99
|
-
desuffix!(aValue,self.
|
99
|
+
desuffix!(aValue,self.dup)
|
100
100
|
end
|
101
101
|
|
102
102
|
def begins_with?(aString)
|
@@ -112,6 +112,7 @@ Time.class_eval do
|
|
112
112
|
end
|
113
113
|
|
114
114
|
# creates a Time object from an integer date stamp (milliseconds since 1970) compatible with Javascript
|
115
|
+
# It will be in local timezone
|
115
116
|
def self.from_ms(aMilliseconds)
|
116
117
|
at(aMilliseconds/1000.0)
|
117
118
|
end
|
@@ -120,24 +121,39 @@ Time.class_eval do
|
|
120
121
|
iso8601(3)
|
121
122
|
end
|
122
123
|
|
124
|
+
# "zoneless time" is a way of representing a time and date eg. 1am 1/1/1970 regardless of timezone.
|
125
|
+
# This is done by converting it to the same time and date, but with the utc flag set
|
126
|
+
# This means that Time.new(1970,1,1).zoneless.to_i will return the same value on any machine
|
123
127
|
def zoneless
|
124
128
|
(self + self.utc_offset).utc
|
125
129
|
end
|
126
130
|
|
127
|
-
# sets the zone without affecting the hour or day
|
128
|
-
|
131
|
+
# This sets the zone without affecting the hour or day
|
132
|
+
# Useful for building a time object eg. New Year in Sydney : Time.new(2016,1,1).to_zone(10)
|
133
|
+
def to_zone(aHours=nil)
|
134
|
+
aHours ||= utc_offset/3600.0
|
129
135
|
self.in_time_zone(aHours)+self.utc_offset-aHours.to_i.hours
|
130
136
|
end
|
137
|
+
|
138
|
+
# Useful for building a UTC/zoneless Time from ms since the epoch
|
139
|
+
# For Freewheeler :
|
140
|
+
# eg. Time.from_zoneless_ms(packet.timems).to_zone(packet.tzm/60)
|
141
|
+
def self.from_zoneless_ms(aTimems)
|
142
|
+
from_ms(aTimems).utc
|
143
|
+
end
|
131
144
|
end
|
132
145
|
|
133
146
|
if defined? ActiveSupport::TimeWithZone
|
134
147
|
ActiveSupport::TimeWithZone.class_eval do
|
148
|
+
# see above
|
135
149
|
def zoneless
|
136
150
|
(self + self.utc_offset).utc
|
137
151
|
end
|
138
152
|
|
153
|
+
# see above
|
139
154
|
# sets the zone without affecting the hour or day
|
140
|
-
def to_zone(aHours)
|
155
|
+
def to_zone(aHours=nil)
|
156
|
+
aHours ||= utc_offset/3600.0
|
141
157
|
self.in_time_zone(aHours)+self.utc_offset-aHours.to_i.hours
|
142
158
|
end
|
143
159
|
end
|
data/lib/buzztools/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: buzztools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gary McGhee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|