sugarcube 0.20.24 → 0.20.25
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/lib/sugarcube/fixnum.rb +4 -0
- data/lib/sugarcube/nsdate.rb +2 -1
- data/lib/sugarcube/version.rb +1 -1
- data/spec/nsdate_spec.rb +8 -0
- data/spec/nsstring_timezone_spec.rb +9 -5
- metadata +1 -1
data/Gemfile.lock
CHANGED
data/lib/sugarcube/fixnum.rb
CHANGED
@@ -15,6 +15,10 @@ class Fixnum
|
|
15
15
|
UIColor.colorWithRed(red, green:green, blue:blue, alpha:alpha.to_f)
|
16
16
|
end
|
17
17
|
|
18
|
+
def nstimezone
|
19
|
+
NSTimeZone.timeZoneForSecondsFromGMT(self)
|
20
|
+
end
|
21
|
+
|
18
22
|
def nth
|
19
23
|
# if the first two digits of rank are between 11 and 20, it's an
|
20
24
|
# 'up-teenth' kinda number
|
data/lib/sugarcube/nsdate.rb
CHANGED
@@ -170,7 +170,8 @@ class NSDate
|
|
170
170
|
date_components.year = self.year
|
171
171
|
|
172
172
|
calendar = NSCalendar.alloc.initWithCalendarIdentifier(NSGregorianCalendar)
|
173
|
-
|
173
|
+
calendar.timeZone = NSTimeZone.timeZoneForSecondsFromGMT(self.utc_offset)
|
174
|
+
date = calendar.dateFromComponents(date_components)
|
174
175
|
|
175
176
|
return date
|
176
177
|
end
|
data/lib/sugarcube/version.rb
CHANGED
data/spec/nsdate_spec.rb
CHANGED
@@ -132,6 +132,14 @@ describe "NSDate" do
|
|
132
132
|
@date.start_of_day.datetime_array.should == [2013, 1, 2, 0, 0, 0]
|
133
133
|
end
|
134
134
|
|
135
|
+
it "should retain the zimeZone" do
|
136
|
+
@date.start_of_day.utc_offset.should == @date.utc_offset
|
137
|
+
end
|
138
|
+
|
139
|
+
it "should respect the timezone" do
|
140
|
+
@date.getutc.start_of_day.getutc.hour.should == 0
|
141
|
+
end
|
142
|
+
|
135
143
|
it "NSDate#start_of_day should be equal to itself" do
|
136
144
|
@date.start_of_day.should == @date.start_of_day
|
137
145
|
end
|
@@ -3,21 +3,25 @@ describe "NSString to NSTimeZone" do
|
|
3
3
|
it "should parse timezone as UTC" do
|
4
4
|
"UTC".nstimezone.secondsFromGMT.should == 0
|
5
5
|
end
|
6
|
-
|
6
|
+
|
7
7
|
it "should parse timezone as Asia/Tokyo" do
|
8
8
|
"Asia/Tokyo".nstimezone.secondsFromGMT.should == 9 * 60 * 60
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
it "should parse timezone as Asia/Tokyo" do
|
12
12
|
"UTC+9".nstimezone.secondsFromGMT.should == 9 * 60 * 60
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
it "should parse timezone as Asia/Tokyo" do
|
16
16
|
"GMT+9".nstimezone.secondsFromGMT.should == 9 * 60 * 60
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
it "should parse timezone as Asia/Tokyo" do
|
20
20
|
"+0900".nstimezone.secondsFromGMT.should == 9 * 60 * 60
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
|
+
it "should parse timezone integer as Asia/Tokyo" do
|
24
|
+
(9 * 60 * 60).nstimezone.secondsFromGMT.should == 9 * 60 * 60
|
25
|
+
end
|
26
|
+
|
23
27
|
end
|