Sha256: 8f6a265e2b229bff012b110c9318624c8508b97f361c7d8c794b3c836ebe455e
Contents?: true
Size: 883 Bytes
Versions: 3
Compression:
Stored size: 883 Bytes
Contents
require_relative 'helper' require 'date' describe 'Adapter' do supported_by Swift::DB::Postgres, Swift::DB::Mysql do describe 'time parsing and time zones' do it 'should set timezone' do assert Swift.db.timezone(8, 0) # +08:00 end it 'should parse timestamps and do conversion accordingly' do assert Swift.db.timezone(8, 30) # +08:30 time = DateTime.parse('2010-01-01 15:00:00+08:30') match = Regexp.new time.to_time.strftime("%F %H:%M") sql = if Swift.db.kind_of?(Swift::DB::Postgres) "select '#{time.strftime('%F %H:%M:%S')}'::timestamp as now" else "select timestamp('#{time.strftime('%F %H:%M:%S')}') as now" end Swift.db.execute(sql) do |r| assert_match match, r[:now].to_s, "parses time and does zone conversion" end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
swift-0.4.3 | test/test_timestamps.rb |
swift-0.4.2 | test/test_timestamps.rb |
swift-0.4.1 | test/test_timestamps.rb |