swift 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.5.1
data/ext/result.cc CHANGED
@@ -88,10 +88,10 @@ static VALUE result_finish(VALUE self) {
88
88
  }
89
89
 
90
90
  // Calculates local offset at a given time, including dst.
91
- size_t client_tzoffset(uint64_t local, int isdst) {
91
+ int64_t client_tzoffset(int64_t local, int isdst) {
92
92
  struct tm tm;
93
93
  gmtime_r((const time_t*)&local, &tm);
94
- return local + (isdst ? 3600 : 0) - mktime(&tm);
94
+ return (int64_t)(local + (isdst ? 3600 : 0) - mktime(&tm));
95
95
  }
96
96
 
97
97
  // pinched from do_postgres
@@ -108,7 +108,7 @@ static void reduce(uint64_t *numerator, uint64_t *denominator) {
108
108
 
109
109
  VALUE typecast_datetime(const char *data, uint64_t len) {
110
110
  struct tm tm;
111
- uint64_t epoch, adjust, offset;
111
+ int64_t epoch, adjust, offset;
112
112
 
113
113
  double usec = 0;
114
114
  char tzsign = 0;
@@ -148,7 +148,7 @@ VALUE typecast_datetime(const char *data, uint64_t len) {
148
148
  reduce(&ajd_n, &ajd_d);
149
149
 
150
150
  VALUE ajd = rb_rational_new(SIZET2NUM(ajd_n), SIZET2NUM(ajd_d));
151
- return rb_funcall(cDateTime, fNewBang, 3, ajd, rb_rational_new(INT2FIX(offset), daysecs), sg);
151
+ return rb_funcall(cDateTime, fNewBang, 3, ajd, rb_rational_new(INT2FIX(adjust), daysecs), sg);
152
152
  }
153
153
 
154
154
  // TODO: throw a warning ?
data/swift.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{swift}
8
- s.version = "0.5.0"
8
+ s.version = "0.5.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Shane Hanna", "Bharanee 'Barney' Rathna"]
data/test/helper.rb CHANGED
@@ -27,6 +27,4 @@ class MiniTest::Spec
27
27
  end
28
28
  end
29
29
 
30
- # All tests run in this timezone.
31
- ENV['TZ'] = ":Australia/Melbourne"
32
30
  MiniTest::Unit.autorun
@@ -3,37 +3,39 @@ require 'date'
3
3
 
4
4
  describe 'Adapter' do
5
5
  supported_by Swift::DB::Postgres do
6
- describe 'time parsing and time zones' do
6
+ %w(Australia/Melboure America/Chicago).each do |timezone|
7
+ describe 'time parsing in %s' % timezone do
8
+ before do
9
+ @db = Swift.db
10
+ ENV['TZ'] = ":#{timezone}"
11
+ end
7
12
 
8
- before do
9
- @db = Swift.db.class.new Swift.db.options.merge(timezone: 'Asia/Kabul')
10
- end
11
-
12
- it 'should parse timestamps and do conversion accordingly' do
13
- time = DateTime.parse('2010-01-01 15:00:00+04:30')
14
- assert_timestamp_like time, fetch_timestamp_at(time), 'parses correctly'
15
- end
13
+ it 'should parse timestamps and do conversion accordingly' do
14
+ time = DateTime.parse('2010-01-01 15:00:00+04:30')
15
+ assert_timestamp_like time, fetch_timestamp_at(time), 'parses correctly'
16
+ end
16
17
 
17
- it 'should parse correctly when DST is on' do
18
- time = DateTime.parse('2010-10-02 20:31:00+04:30')
19
- assert_timestamp_like time, fetch_timestamp_at(time), 'DST on'
20
- end
18
+ it 'should parse correctly when DST is on' do
19
+ time = DateTime.parse('2010-10-02 20:31:00+04:30')
20
+ assert_timestamp_like time, fetch_timestamp_at(time), 'DST on'
21
+ end
21
22
 
22
- it 'should parse correctly when DST is off' do
23
- time = DateTime.parse('2010-04-04 20:31:00+04:30')
24
- assert_timestamp_like time, fetch_timestamp_at(time), 'DST off'
25
- end
23
+ it 'should parse correctly when DST is off' do
24
+ time = DateTime.parse('2010-04-04 20:31:00+04:30')
25
+ assert_timestamp_like time, fetch_timestamp_at(time), 'DST off'
26
+ end
26
27
 
27
- def fetch_timestamp_at value
28
- sql = "select '%s'::timestamp with time zone as now" % value.strftime('%F %T%z')
29
- @db.execute(sql)
30
- @db.results.first.fetch(:now)
31
- end
28
+ def fetch_timestamp_at value
29
+ sql = "select '%s'::timestamp with time zone as now" % value.strftime('%F %T%z')
30
+ @db.execute(sql)
31
+ @db.results.first.fetch(:now)
32
+ end
32
33
 
33
- def assert_timestamp_like expect, given, comment
34
- match = Regexp.new expect.to_time.strftime('%F %T')
35
- assert_kind_of DateTime, given
36
- assert_match match, given.strftime('%F %T'), comment
34
+ def assert_timestamp_like expect, given, comment
35
+ match = Regexp.new expect.to_time.strftime('%F %T')
36
+ assert_kind_of DateTime, given
37
+ assert_match match, given.strftime('%F %T'), comment
38
+ end
37
39
  end
38
40
  end
39
41
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 5
8
- - 0
9
- version: 0.5.0
8
+ - 1
9
+ version: 0.5.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Shane Hanna