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 CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sugarcube (0.20.23)
4
+ sugarcube (0.20.25)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -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
@@ -170,7 +170,8 @@ class NSDate
170
170
  date_components.year = self.year
171
171
 
172
172
  calendar = NSCalendar.alloc.initWithCalendarIdentifier(NSGregorianCalendar)
173
- return calendar.dateFromComponents(date_components)
173
+ calendar.timeZone = NSTimeZone.timeZoneForSecondsFromGMT(self.utc_offset)
174
+ date = calendar.dateFromComponents(date_components)
174
175
 
175
176
  return date
176
177
  end
@@ -1,3 +1,3 @@
1
1
  module SugarCube
2
- Version = '0.20.24'
2
+ Version = '0.20.25'
3
3
  end
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sugarcube
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.24
4
+ version: 0.20.25
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: